Redirecting PHP Page After Function Execution
In PHP, it is possible to execute a function and then redirect the user to a different page within the same root folder. This can be achieved using the header() function.
Code Example:
Consider the following PHP code snippet:
if (...) { // I am using echo here. } else if ($_SESSION['qnum'] > 10) { session_destroy(); echo "Some error occured."; // Redirect to "user.php". header("Location: user.php"); exit(); }
Explanation:
Considerations:
The above is the detailed content of How to Redirect a PHP Page After Function Execution Using header()?. For more information, please follow other related articles on the PHP Chinese website!