Retrieve page name in php

Many people facing this problem for many kind of situations like … create dynamic javascript or css menu..,  navigation,  hit counter… for page..

you can use set variable names for page.  second good way is use this function for print page name $_SERVER[“PHP_SELF”]

or if you want only page name than use this script

<?php

$pagename=pathinfo($_SERVER[“PHP_SELF”]);
$pagename=$pagename[“basename”];

echo $pagename;

?>

This is some more helpfull code…

$url = $_SERVER[‘REQUEST_URI’];
echo $url;
echo “<br>”;
$array = explode(“/”,$url);
echo $array[2]; ///which folder would you want to access ?
echo “size of array = “.sizeof($array).”<br>”;

URL unicode is another method for Creating Pretty or Clean Url and creating breadcrumbs

Advertisements