jac.kock Posted April 28, 2012 Share Posted April 28, 2012 hi, i want to resize the font-size in my website ussing php butt it doenst work why ?? can someone help me to get it working?? <html> <head> <title>Een website naam.</title> </head> <!-- this doent work, this was a test to see ik ik works!! --> <style type='text/css'> html{ font-size: 300%; } </style> <!-- this is my php code for working with resize!! This must got to work !!! --> <!-- Start varible font-size --> <?php //start session Session_start(); $_SESSION['FontSize']='300'; // check default fontsize if($_SESSION['FontSize']=='') { ?> <style type='text/css'> body { font-size: 100%; } </style> <?php } else { echo "<style type='text/css'>body { font-size: ".$_SESSION['FontSize']."%; } </style>"; } ?> <!-- end varible font-size --> how can tell my wath i do wrong??? thnx, Quote Link to comment https://forums.phpfreaks.com/topic/261755-want-to-resize-font-size-with-php/ Share on other sites More sharing options...
WebCheez Posted April 28, 2012 Share Posted April 28, 2012 First suggestion: use body instead of html for your formatting. Like: <style type='text/css'> html{ font-size: 300%; } </style> Even so, you should just delete that at the beginning so the font size will be variable. if($_SESSION['FontSize']=='') { ?> <style type='text/css'> body { font-size: 100%; } </style> <?php } The browser doesn't know that the <style> is in an if statement. Any thing that is not in the <?php ?> tags is ignored by PHP, but even if you didn't drop out of PHP. I would suggest: if(!isset($_SESSION['FontSize'])) { echo '<style type='text/css'> body { font-size: 100%; } </style>'; } That will output your style to the browser, so it's interpreted only when FontSize is blank. I also added an isset so that it checks if the variable is not set, rather than if it is blank. There may be a few other errors, I'm not sure; I'm no expert. Quote Link to comment https://forums.phpfreaks.com/topic/261755-want-to-resize-font-size-with-php/#findComment-1341347 Share on other sites More sharing options...
jac.kock Posted April 28, 2012 Author Share Posted April 28, 2012 hi, i have tested whit only this: if(!isset($_SESSION['Size'])) { echo '<style type='text/css'> body { font-size: 300%; } </style>'; } like you said, butt my text stays the same??? why??? see http://nieuw.pc-hulp-online.nl/index.php thnx Quote Link to comment https://forums.phpfreaks.com/topic/261755-want-to-resize-font-size-with-php/#findComment-1341361 Share on other sites More sharing options...
floridaflatlander Posted April 28, 2012 Share Posted April 28, 2012 Put your url in here at http://validator.w3.org/ . It says you have 8 errors, 1 is no doc type and another says doc type does not allow style here. This link and firefoxes firebug are handy tools. Quote Link to comment https://forums.phpfreaks.com/topic/261755-want-to-resize-font-size-with-php/#findComment-1341367 Share on other sites More sharing options...
jac.kock Posted April 28, 2012 Author Share Posted April 28, 2012 Put your url in here at http://validator.w3.org/ . It says you have 8 errors, 1 is no doc type and another says doc type does not allow style here. This link and firefoxes firebug are handy tools. butt it dont said how to fix it!! Quote Link to comment https://forums.phpfreaks.com/topic/261755-want-to-resize-font-size-with-php/#findComment-1341370 Share on other sites More sharing options...
Drummin Posted April 28, 2012 Share Posted April 28, 2012 Move the code to the head section. Quote Link to comment https://forums.phpfreaks.com/topic/261755-want-to-resize-font-size-with-php/#findComment-1341378 Share on other sites More sharing options...
jac.kock Posted April 28, 2012 Author Share Posted April 28, 2012 Move the code to the head section. moved and still no change?? wath's the problem now with it?? http://nieuw.pc-hulp-online.nl thnx, Quote Link to comment https://forums.phpfreaks.com/topic/261755-want-to-resize-font-size-with-php/#findComment-1341381 Share on other sites More sharing options...
Drummin Posted April 28, 2012 Share Posted April 28, 2012 It could be a matter of 300% of what? Without testing I'm not 100% sure on this but you might try defining a default size, then go 300%. I also see you're using "if (!isset" which I assume is for testing. <style type='text/css'> body { font-size: 11px; } </style> if(!isset($_SESSION['Size'])) { echo '<style type='text/css'> body { font-size: 300%; } </style>'; } EDIT: You need a doctype declaration. replace your <html> with this <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> Quote Link to comment https://forums.phpfreaks.com/topic/261755-want-to-resize-font-size-with-php/#findComment-1341390 Share on other sites More sharing options...
jac.kock Posted April 28, 2012 Author Share Posted April 28, 2012 thnx all it works now yea thanx, Quote Link to comment https://forums.phpfreaks.com/topic/261755-want-to-resize-font-size-with-php/#findComment-1341410 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.