Is this possible? (automated browser title)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mosqwik
Spammer :|
Posts: 1
Joined: Thu Sep 27, 2007 1:18 am

Is this possible? (automated browser title)

Post 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!
User avatar
Josh1billion
Forum Contributor
Posts: 316
Joined: Tue Sep 11, 2007 3:25 pm

Post 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()
Post Reply