Jump to content

want to resize font-size with php !


jac.kock

Recommended Posts

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,

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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">

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.