Re: help with classes

From: Date: Tue, 13 Feb 2001 12:35:47 +0000
Subject: Re: help with classes
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-39401@lists.php.net to get a copy of this message
You can allso do this: //foo.class.php class Foo{ var $bar; function Foo($bar){ $this->bar = $bar; } } //foo.php include("foo.class.php"); $bar = "1234"; $foo = new Foo($bar); //Now: $foo->bar = "1234" Regards: Marcus Rasmussen *********** REPLY SEPARATOR *********** On 14-02-2001 at 15:52 Joseph H Blythe wrote: >On Mon, 12 Feb 2001 21:04:30 -0800 >Joe wrote: > >JC> Is this closer to what you were looking for? >JC> - Joe >JC> >JC> <?PHP >JC> >JC> class Foo { >JC> >JC> var $bar; >JC> >JC> function mymethod(){ >JC> >JC> global $foo; >JC> $this->bar = $foo; >JC> >JC> } >JC> >JC> } >JC> >JC> $foo = "hello world"; >JC> >JC> echo "<html><body>"; >JC> >JC> $cls = new foo(); >JC> $cls->mymethod(); >JC> echo $cls->bar; >JC> >JC> echo "</body></html>"; >JC> ?> >JC> > >hmm sort of is, basically this works: > >// Foo.class.php >class Foo { > >var $bar; > > setBar($bar) { > $this->bar = $bar; > } > >} > >// foo.php >include("Foo.class.php"); >$foo = new Foo; >$bar = "1234567789"; >$foo->setBar($bar); > >Regards, > >Joseph > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#39401) next »