common Posted February 10, 2009 Share Posted February 10, 2009 i just started studiing php. And got this assignment. In the assignment i need to change the font size with every refresh, can someone please tell me what the coding should look like? Quote Link to comment https://forums.phpfreaks.com/topic/144623-text-size-in-php/ Share on other sites More sharing options...
premiso Posted February 10, 2009 Share Posted February 10, 2009 rand would be your best bet. Take a look into that. Quote Link to comment https://forums.phpfreaks.com/topic/144623-text-size-in-php/#findComment-758894 Share on other sites More sharing options...
common Posted February 10, 2009 Author Share Posted February 10, 2009 ok, uhm but how can i use it, my coding is basicly like this: $a1=rand(10,30); print "<center> <div>text...</div>"; Can I just use the style attribute in the div tag? If i want the text to change Quote Link to comment https://forums.phpfreaks.com/topic/144623-text-size-in-php/#findComment-758901 Share on other sites More sharing options...
premiso Posted February 10, 2009 Share Posted February 10, 2009 How do you normally set a font-size? Are you required to use the div tag? Why not make it easier to just use the <font> tag? No styling required, unless that is what the assignment calls for. Look up on the <font> tag in html to see how it is used. From there, you can hopefully find out. If not read up on echo and print on how to print/echo variables in PHP. Quote Link to comment https://forums.phpfreaks.com/topic/144623-text-size-in-php/#findComment-758904 Share on other sites More sharing options...
common Posted February 10, 2009 Author Share Posted February 10, 2009 Ok i will look up into that. Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/144623-text-size-in-php/#findComment-758905 Share on other sites More sharing options...
killah Posted February 10, 2009 Share Posted February 10, 2009 If you want it to go from small to large: <?php session_start(); $start = 1; $top = 24; if( !isset($_SESSION['size']) ) { echo '<font size="'.$start.'">We start with 1.</font><br><br>Please refresh page'; $_SESSION['size'] = 2; } else if($_SESSION['size'] == $top) { echo '<font size="'.$_SESSION['siz'].'">We end our font size with '.$top.'</font>'; } else if($_SESSION['size'] > $top) { echo '<font size="'.$_SESSION['size'].'">Next Size: '.$_SESSION['size'].'</font><br><br>Please refresh page'; $_SESSION['size']++; } ?> Of course here is a random size: <?php $size = rand(1,24); echo '<font size="'.$size.'">Our random size font is '.$size.'</font><br><br>Please refresh page'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/144623-text-size-in-php/#findComment-758906 Share on other sites More sharing options...
premiso Posted February 10, 2009 Share Posted February 10, 2009 If you want it to go from small to large: Dude, how is he going to learn if you just give it to him. This is a homework assignment, make them actually learn how to do it on their own, not give them the answer. Quote Link to comment https://forums.phpfreaks.com/topic/144623-text-size-in-php/#findComment-758907 Share on other sites More sharing options...
killah Posted February 10, 2009 Share Posted February 10, 2009 If you want it to go from small to large: Dude, how is he going to learn if you just give it to him. This is a homework assignment, make them actually learn how to do it on their own, not give them the answer. My bad Quote Link to comment https://forums.phpfreaks.com/topic/144623-text-size-in-php/#findComment-758909 Share on other sites More sharing options...
coder_ Posted February 10, 2009 Share Posted February 10, 2009 Besides that, font tag is deprecated. So dont use it. Quote Link to comment https://forums.phpfreaks.com/topic/144623-text-size-in-php/#findComment-758911 Share on other sites More sharing options...
premiso Posted February 10, 2009 Share Posted February 10, 2009 Besides that, font tag is deprecated. So dont use it. For an assignment, as long as the teacher does not care, I would use it. My bad np, the problem arises is when someone actually does use that code, which a teacher can generally tell a beginners code from someone who knows php code and they start searching, find this topic and wham, he is in trouble for that. I do understand that, it would really be his problem, but by just helping him along, a teacher would not punish them for that and they learn it. Some times just pointing out the right direction is great But it is like the old saying, "You give a mouse a cookie....", you keep giving him stuff and he keeps wanting you to give him more, you teach him it, he learns it and will learn how to find solutions on his own. Quote Link to comment https://forums.phpfreaks.com/topic/144623-text-size-in-php/#findComment-758915 Share on other sites More sharing options...
killah Posted February 10, 2009 Share Posted February 10, 2009 But it is like the old saying, "You give a mouse a cookie....", you keep giving him stuff and he keeps wanting you to give him more, you teach him it, he learns it and will learn how to find solutions on his own. Ive only heard the term "You give a mouse a cookie.. he will ask for milk" Quote Link to comment https://forums.phpfreaks.com/topic/144623-text-size-in-php/#findComment-759076 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.