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
This entry was posted in PHP and tagged , , by Purab Kharat. Bookmark the permalink.

About Purab Kharat

I am WordPress and Drupal Architect. I worked on many technologies like Ruby on Rails, Flex, PHP etc... I am Purab Kharat from India, Pune. I love to play chess and listen music and read books. I work in SY Smartsourcing Global Pvt Ltd in Princeton, NJ, USA. Now I am living at Plainsboro, 164 Hampshire Drive, Princeton Meadows, NJ. I have more then Ten years experience in Web Application Development (Specially in Php 5.0, Ruby on Rails, Mysql 5.0, RIA, Wordpress, Drupal, Joomla, Ecommerce)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s