Support Forums
[tut] Random Page Titles - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: [tut] Random Page Titles (/showthread.php?tid=83)

Pages: 1 2


[tut] Random Page Titles - Extasey - 10-04-2009

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!


RE: [tut] Random Page Titles - MyNameIs940 - 10-04-2009

Wow this is great, I will for sure be using this on my website, thanks.


RE: [tut] Random Page Titles - Viciousness - 10-04-2009

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


RE: [tut] Random Page Titles - Skawke - 10-04-2009

Wow, never knew this trick -.-


RE: [tut] Random Page Titles - Extasey - 10-04-2009

(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


RE: [tut] Random Page Titles - Kernel32 - 10-05-2009

Thanks for this share i will use it Smile


RE: [tut] Random Page Titles - GizSho - 10-05-2009

That's so simple, and can't really be used for anything, but it's a nice little feature for your website ;)


RE: [tut] Random Page Titles - Extasey - 10-05-2009

(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!


RE: [tut] Random Page Titles - Pirata Nervo - 10-05-2009

If mt_rand exists, use mt_rand instead of rand ;)


RE: [tut] Random Page Titles - Dr.Viper - 10-08-2009

Nice, thanks.
Didn't know this was possible...