Skip to content
PHP Logo

How can PHP be used to instruct the browser to go back a page?

To instruct the browser to go back a page using PHP, you can use the `header` function with the `Location` parameter set to `$_SERVER['HTTP_REFERER']`. This will redirect the browser back to the previous page.

php
<?php
header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
?>