There can be various reasons why Header location function is not executed when called from a php file. Here is a check-list to solve such a issue when encountered.
1. Check that there are no print,echo\'s outputs before the header is being called.
2. There should be no white spaces before <?php and after ?>.
3. Check for UTF-8 BOM(Byte-Order-Mark)
4. There should be no error messages before the header call.
5. If there are include functions calling other php files before header call,
check all above steps(about points 1 to 4) for these files.
⚠️ If still the error is not resolved, one of the solution is to enclose you php file with ob_start() and ob_end_flush().
Example:
<?php
ob_start();
// your code goes in here
ob_end_flush();
?>
More Posts related to PHP,
- PHP drag and drop file upload tutorial using dropzone.js
- Copy file from one directory to other in Php
- PHP Base64 encoding decoding a variable
- macOS - cannot calculate MAC address: Using fd 9 hv_vm_create HV_ERROR [PHP XAMPP]
- Upload Pdf file using PHP Script
- Call PHP function on Button click using jquery ajax
- PHP Code for sending Emails
- PHP header location function not called
- Delete file using PHP code : unlink()
- PHP Warning: Cannot modify header information - headers already sent
- Failed to load resource: net::ERR_CACHE_MISS PHP
- Upload docx file using PHP script
- PHP 301 Redirect Permanently
- PHP Script to Upload Images to Server
- Installing vue.js in Laravel 8
- Remove URL Forward Slash Before Single or Double quotes in php.ini
- How to destroy PHP session()
- PHP Fatal error : Call to a member function bind_param() on a non-object
- 403 forbidden error for Image
More Posts:
- How to stop/start/restart apache server using command [Ubuntu] - Ubuntu
- Fix java.net.ProtocolException: Invalid HTTP method - Java
- JSON Nest Objects Example: JSON Tutorial - Json-Tutorial
- Install specific JRE on Ubuntu using apt - Ubuntu
- Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end users experience - Java
- list of jars required for hibernate 4.x.x - Java
- The Android Virtual Device myEmulator is currently running an emulator and cannot be deleted. - Android
- Your Android SDK is out of date or is missing templates. Please ensure you are using SDK version 22 or later. - Android