Support Forums

Full Version: [tut] Random Page Titles
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I was interested in doing this a few months ago and found that it was actually much easier then it seems!

Randomising the page titles is just a neat little "Easter egg", if you will" that simply changes the title of the page everytime it is loaded.
an example of this is:
www.bungie.net
where sometimes the title is simply bungie.net and other times it says things such as "xbox live and pizza 24/7" or "so we made this game called halo"

here is the code:
PHP Code:
<?php
site name
[1] = "Cameron's Privates, now with crabs!"
site name [2] = "Cameron's Privates, dont you love them?";
site name[3] = "Cameron's Privates, I've got wood... in my fire!";
site name[4] = "Cameron's Privates";

$random_select rand(14);
echo 
$title[$random_select];
?>

as we can see, the titles you want to add are in the 1st section of the code, and the second section of the code is what automates the changing of titles. you will have to adjust it to the amount of titles you have.

eg. if you have 10 titles your code will look like this (in the 2nd section)
PHP Code:
$random_select rand(110);
echo 
$title[$random_select]; 

instead of:
PHP Code:
$random_select rand(14);
echo 
$title[$random_select]; 

simple isn't it!

By the way, cameronsprivates.com is my proxy. Just incase you were wondering!
Wow this is great, I will for sure be using this on my website, thanks.
Cool tutorial.

Is Cameron's Privates your site? Just curious, if it's rather unknown I may be able to use it at school. Smile
Wow, never knew this trick -.-
(10-04-2009, 08:43 PM)MreGSX Wrote: [ -> ]Cool tutorial.

Is Cameron's Privates your site? Just curious, if it's rather unknown I may be able to use it at school. Smile

yes it is my site, but it will be going down soon as i cant be bothered to pay for the hosting, and havn't been using it enough to make it worth it!
It used to be password protected so the school couldn't look at its content if it was under suspicion, hence the "In the circle" subheading. Its school holidays now so i don't care for now.
I'd be sure to make a password for anyone who pays for hosting ;D
Thanks for this share i will use it Smile
That's so simple, and can't really be used for anything, but it's a nice little feature for your website ;)
(10-04-2009, 07:09 PM)Extasey Wrote: [ -> ]Randomising the page titles is just a neat little "Easter egg", if you will" that simply changes the title of the page

;D i know

Positive REP is always appreciated!
If mt_rand exists, use mt_rand instead of rand ;)
Nice, thanks.
Didn't know this was possible...
Pages: 1 2