PHP Redirect Made Simple

In PHP, the functionality of page redirection can be achieved by using the header function. The header function is used to send raw HTTP headers. Here is a simple example:

// 跳转到另一个页面
header("Location: http://www.example.com");
exit();

In the example above, when a user accesses the page, they will immediately be redirected to the page http://www.example.com. It is important to note that there should be no output before calling the header function, as it could result in errors. The final exit function is used to terminate the script’s execution and ensure the redirection of the page proceeds smoothly.

bannerAds