Re: help with classes

From: Date: Tue, 13 Feb 2001 13:59:52 +0000
Subject: Re: help with classes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39412@lists.php.net to get a copy of this message
on 2/13/01 12:04 AM, Joe Conway at jconway2@home.com wrote: > <?PHP > > class Foo { > > var $bar; > > function mymethod(){ > > global $foo; > $this->bar = $foo; > > } > > } > > $foo = "hello world"; > > echo "<html><body>"; > > $cls = new foo(); > $cls->mymethod(); > echo $cls->bar; > > echo "</body></html>"; > ?> This can be simplified by: <?php class Foo { function Foo($foo="") { $this->bar = $foo; } } $foo = "Hello World"; $cls = new Foo($foo); echo $cls->bar; ?> -- Jesse Swensen swensenj@bellsouth.net

« previous php.general (#39412) next »