Get the full URL By PHP

    1100623 VIEW 1 0

To get the current page full url, You need to use superglobal variable $_SERVER. The $_SERVER is a built-in variable of PHP, which is used to get the current page URL. It is a superglobal variable, means it is always available in all scope

<?php  

$protocol = ((!emptyempty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";  
$full_url= $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];  
echo $full_url;  
?>  




Related Topics
=> Function to Get mime type By PHP
=> Check if a string contains a specific word
=> Get the client IP address by PHP
=> Get the full URL By PHP