Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[tut] Random Page Titles
#1
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!
Reply
#2
Wow this is great, I will for sure be using this on my website, thanks.
Reply
#3
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
[Image: MreGSXsigcopy.png]

Reply
#4
Wow, never knew this trick -.-
Reply
#5
(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
Reply
#6
Thanks for this share i will use it Smile
Reply
#7
That's so simple, and can't really be used for anything, but it's a nice little feature for your website ;)
Reply
#8
(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!
Reply
#9
If mt_rand exists, use mt_rand instead of rand ;)
Reply
#10
Nice, thanks.
Didn't know this was possible...
Giveaway - A Rare Autoblog Guide. PM me for it, by clicking here.

Hey guys. It's Dr.Viper from HF. Howdy.
o HTML and PHP based website design.
o SEO/SEM services.
o Logo & GFX Design services.
And above all, everyone know what i'm good at HF... So,
o Security Consultancy.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [TUT] PHP Password Protected Page PurpleHaze 23 6,935 05-20-2011, 02:56 AM
Last Post: stephen5565
  Random Image PHP Matt G 13 3,786 11-24-2010, 01:21 PM
Last Post: Sam
  Random Signature script Gaijin 8 5,181 01-24-2010, 05:08 PM
Last Post: Gaijin
  Advanced Random Password Generator zone 2 1,217 11-06-2009, 09:16 PM
Last Post: zone

Forum Jump:


Users browsing this thread: 1 Guest(s)