get page name from current url using php

Many people facing this problem for many kind of situations like, get page name from current url using php, Here we given php code for retrieve page name  … create dynamic javascript or css menu..,  navigation,  hit counter… for page..

get page name from current url using php

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)."
";

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