Page 1 of 1

Is this possible? (automated browser title)

Posted: Fri Sep 28, 2007 3:55 pm
by Mosqwik
Hi,
Something that would be really useful for a new project im working on would be to have automated browser titles using some php code in the <title> tags.
The only way I can think of doing this is by having the php code read the url im using for navigation, e.g. /windows/atari2600/ and use that data, edit it and have it display as 'Windows > Atari 2600'
Has this kind of thing been done before? are there any other common ways of doing this? Also are there any tutorials around?
Thanks!

Posted: Fri Sep 28, 2007 4:01 pm
by Josh1billion
Something like Wikipedia articles?

That'd be pretty easy really...

Code: Select all

<?php
$url = $_SERVER['SCRIPT_NAME']; // if I understand this line correctly, this would be "/server/atari2600" in your example

// you can parse $url here into the different words if you like.. I would suggest you use an underscore ( _ ) for spaces, so you'd have /server/atari_2600 instead

print "<title>$url</title>";
?>
Hope that helps. :)

Note: for parsing the $url variable, you may want to look into the functions strstr() and substr()