changing $font variable

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
entebbe
Forum Newbie
Posts: 1
Joined: Thu May 07, 2009 11:43 am

changing $font variable

Post by entebbe »

I'd like to change the font of a webpage every 25 seconds (in order to decide between a number of options).

I tried this, but it's definetly not working:

Code: Select all

 
<?php 
$i = 0;
$fonts = array('Trebuchet MS', 'Arial', 'Helvetica', 'sans-serif', 'Verdana', 'Georgia', 'Tahoma', 'Palatino', 'Gill Sans');
$font = $fonts[$i];
echo 'style="font-family: '.$font.';">';
$i = ($i + 1) % 9;
if (time() % 25 == 0) {
  $i += 1;}
?>
 
PS I did not forget that I have to click the refresh button. What did I do wrong?
Last edited by Benjamin on Thu May 07, 2009 11:52 am, edited 1 time in total.
Reason: Added [code=php] tags.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Re: changing $font variable

Post by hawleyjr »

You will need to use javascript to do this. PHP is server side only.
Post Reply