Classes within classes

From: Date: Fri, 27 Jun 2003 10:09:37 +0000
Subject: Classes within classes
Groups: php.general 
Request: Send a blank email to php-general+get-153085@lists.php.net to get a copy of this message
Hiya, It would be useful for me to be able to use a class within another class and I don't know if that's permissable in PHP. Here's an example of what I'm trying to do. Is it just simply not permitted or am I going about it the wrong way? Thanks in advance for any help, Dave Code follows: ===================================================================== class CSSFont { var $family ='Arial'; var $size ='12pt'; var $style = 'none'; function Output() { $out = "\n"; $out .= "font-family:".$this->family.";\n"; $out .= "font-size:".$this->size.";\n"; $out .= "font-style:".$this->style.";\n"; return $out; } } class CSSBorder { var $font1= new CSSFont; var $font2= new CSSFont; function Output() { $out = $this->font1->Output(); $out .= " other stuff goes here "; $out .= $this->font2->Output(); } } ===================================================================== --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.491 / Virus Database: 290 - Release Date: 18/06/2003

« previous php.general (#153085) next »