469,636 Members | 1,581 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,636 developers. It's quick & easy.

Object's fontSize attribute not changing

gomescoder
HI TSDN Pals,


I am trying to create an object to modify its colour, size, message attributes on the fly using OOP concept...

Everything works fine with this code but the problem is the font size is not changing. I have highlighted the problem area in the below snippet.

// Start of the Snippet
-------------------------------
Expand|Select|Wrap|Line Numbers
  1. class theme{
  2.  
  3. var $fontColour;
  4. var $fontSize;
  5. var $amessage;
  6.  
  7. function __construct($fontColour,$fontSize){        // attribute intialization
  8.  
  9. $this->fontColour=$fontColour;
  10. $this->fontSize=$fontSize;
  11.  
  12. }
  13.  
  14. function accessMessageFetch() {         // amessage attrirbute fetching from file
  15.  
  16. $fd=fopen("includes/amessage.inc", "r+") or die ("Can't open the file amessage.inc");
  17. $fstring =fread($fd, filesize("includes/amessage.inc"));
  18. $this->amessage=$fstring;
  19. fclose($fd);
  20.  
  21. }
  22.  
  23. function accessDisp(){                    // display function
  24.  
  25. /*************************************************
  26. *    Problem Area:
  27. *************************************************/
  28. echo "<span><font color=/'".$this->fontColour."/' size=/'".$this->fontSize."/'>".$this->amessage."</font></span>";  // Problem area
  29.  
  30. }
  31.  
  32. } // end of class
  33.  
  34. $themeSetting=new theme('#3671AD',+2);
  35. $themeSetting->accessMessageFetch();
  36. $themeSetting->accessDisp();
[Please use CODE tags when posting source code. Thanks! --pbmods]

Please advice...
Jun 22 '07 #1
3 1067
pbmods
5,821 Expert 4TB
Heya, gomescoder. Welcome to TSDN!

Try adding a style attribute to your span instead of creating a (deprecated) font tag:

Expand|Select|Wrap|Line Numbers
  1. echo <<<EOT
  2. <span style="color:{$this->fontColour};font-size:{$this->fontSize};">{$this->amessage}</span>
  3. EOT;
  4.  
Jun 22 '07 #2
Hi Pbmods,

Your solution worked thatz great

additionally i have learnt that you need to pass the font-size value along with the suffix 'px'

From my previous posting there is a bug in line 34.

Code: ( Php )

34: $themeSetting=new theme('#3671AD',+2);

--END OF CODE

The above line 34 should be written as

34: $themeSetting=new theme('#3671AD','20px'); // Change in the Font-size argument


Thanks Pbmods
Jun 23 '07 #3
pbmods
5,821 Expert 4TB
Heya, gomescoder.

Your solution worked thatz great
Excellent. You can leave the money on the table. Hah, just kidding. Glad to hear you were able to get it working.

Thanks for posting your solution in case other members run into the same problem.

Good luck with your project. Post back anytime if you need anything!
Jun 23 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.