well I am generating pages from database and I want to keey SEO friendly titles for every page. The pages are like dealers-of-variable.php so I want the page title to be <title>Delaers of Variable</title> How can I do this ? mind you,first I have to know the name of the page using php code and than have to modify it to create title. I think the code will be something like this. <?php $page_name //we have to find this..but how ??? $title=[using regexp make page name into proper titles] ?> <title><echo $title></title> Thanks
It is better to use $_SERVER['SCRIPT_NAME']. $_SERVER["REQUEST_URI"] returns the query string after the script name, it is not needed here. Check out the article about the difference between SCRIPT_NAME, REQUEST_URI and PHP_SELF.
Hi poseidon, You can pull out the filename without the extension by using: $file = basename($path, ".php"); // $file is set to actual name without the extension //OR you can use pathinfo() if many types of files are used besides php PHP: To get rid of the dashes, $title=str_replace("-", " ", $file); PHP: