Search code examples
phpdynamicdynamic-arraysssitoolbars

grabbing the url from a page php is embedded in


I am trying to create a toolbar on the bottom of my page using php. It should be dynamic and it should not include links for the page it is embedded in. When i use the following code.

$path = $_SERVER['SCRIPT_NAME'];

It grabs the url of the page toolbar.php. I am attempting to grab the page the toolbar PHP is embedded in. Any Ideas?


Solution

  • Use $_SERVER['REQUEST_URI']

    $full_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    

    Or...

    $page = basename($_SERVER['PHP_SELF']);