How to Allow a PHP Header Anywhere
PHP uses headers to interface with the server and the user's browser. You must include the PHP header section in your PHP code to allow a PHP header to run on the server when the user opens the file. The header code is placed at the top of the file, so it can run before any of the content code runs in the browser.
Instructions
-
-
1
Right-click the PHP file you want to use to include a header and click "Open With." Click your preferred PHP editor in the list of programs.
-
2
Add the header at the top of the file. You must add the header code above the main HTML tag to avoid any errors. For instance, if you want to redirect the user to a new location, add the following code:
header("Location: http://newlocation.com/");
Change the "newlocation.com" to the redirected target page.
-
-
3
Save the file and open the new file in your browser to test the changes. The header runs before any HTML code shows. For instance, if you added a redirect, the page redirects to a new Web page address.
-
1