Re: Problem using Classes like Structs in PHP 4

From: Date: Thu, 07 Sep 2000 08:28:12 +0000
Subject: Re: Problem using Classes like Structs in PHP 4
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-15672@lists.php.net to get a copy of this message
On Thu, Sep 07, 2000 at 10:25:43AM +0200, Martin wrote: > Try new first();. I think, a class should have an (emtpy) constuctor. > > Martin > > > Michael Crusi wrote: > > > I set up classes in this way: > > > > class first { > > var $a; > > var $b; > > } > > > > class second { > > var $c; > > var $d= new first; > > } only static initializers are allowd in 4.0 - you need to use a constructor: class second { var $c; var $d; function second(){ $this->d = new first; } } > > > > In PHP 3, this use of classes like a struct worked just fine. In PHP > > 4.0.1, I get a parse error when php parses the "var $d...." line. > > > > Can anyone clue me in on what has changed? > > > > Thanks! > > > > Mike > > > > -- > > 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 > > > -- > 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 -- Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" Digital Collections Phone +49 40 235350 Fax +49 40 23535180 Hammerbrookstr. 93 20097 Hamburg / Germany

« previous php.general (#15672) next »