PHP Page Redirect

In this tutorial, i would like to show you how to redirect in PHP.We use header() function in PHP to redirect to new location.The header function sends raw header data to the client web browser and in this case sends a 302 status code which instructs the browser to redirect to the given location.

The following php script redirects the user to /index.php within the same site:

Note : Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

Arjun
I am Arjun from Hyderabad (India). I have been working as a software engineer from last 7+ years, and its my passion to learn new things and implement them as a practice. Aside from work, I likes gardening and spending time with pets.
DMCA.com Protection Status