Retrieve page name in php

Written by Sony on 27 February 2008 in , , | Add Comments

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

You might also like

how to send a variable value from an Iframe back to its parent?
Page scrolling up or down through javascript
how to register dynamic and multiple sidebar in wordpress
In page pop up javascripts or modalbox
Really Simple History – History for Ajax

Leave a Reply

Wordpressapi is developer code book.
wordpressapi on Facebook
© 2010 Wordpressapi. All Rights Reserved. Reproduction without explicit permission is prohibited.