The previous URL in PHP can be obtained using the $_SERVER['HTTP_REFERER']
variable. This variable contains the URL of the previous page that the user visited.
Here is an example of how to use it:
<?php // Get the previous URL $previousUrl = $_SERVER['HTTP_REFERER']; // Display the previous URL echo "Previous URL: " . $previousUrl; ?>
When you run this code in a PHP file and visit that file from another page, it will display the URL of the previous page.
However, please note that the $_SERVER['HTTP_REFERER']
variable is not always reliable. It can be easily manipulated or blocked by the user’s browser, so you should not rely on it for critical functionality.
- Protobuf compiler version doesn’t match library version
- Primeng table date filter not working
- Parse issue (xcode): module ‘fluttertoast’ not found
- Pysimplegui hide element
- Permission denied to generate login hint for target domain.
- Php delete files older than 1 hour
- Pass setstate to child typescript
- Parsererror: unexpected end of data
- Pyspark startswith multiple values
- Php get localstorage value