How can PHP be used to detect if a URL was accessed using HTTPS instead of HTTP?
To detect if a URL was accessed using HTTPS instead of HTTP in PHP, you can check the value of the $_SERVER['HTTPS'] variable. If the value is set to 'on', then the URL was accessed using HTTPS. You can use this information to perform specific actions or validations based on the protocol used.
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'){
echo 'This URL was accessed using HTTPS';
} else {
echo 'This URL was not accessed using HTTPS';
}