How to get the current full URL in PHP

2 Answers

0 votes
$url = (isset($_SERVER['HTTPS']) ? "https" : "http")."://$_SERVER[HTTP_HOST]$_SERVER[PHP_SELF]";
 
echo $url;

 
/*
run:
 
http://localhost/allonpage.com/test.php
 
*/

 



answered Jun 14, 2018 by avibootz
edited Feb 26, 2019 by avibootz
0 votes
$url = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
 
echo $url;

 
/*
run:
 
http://localhost/allonpage.com/test.php
 
*/

 



answered Feb 26, 2019 by avibootz

Related questions

1 answer 262 views
1 answer 185 views
1 answer 223 views
2 answers 384 views
2 answers 415 views
1 answer 237 views
...