Re: Initializing class properties

From: Date: Thu, 30 Nov 2000 01:50:20 +0000
Subject: Re: Initializing class properties
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-27953@lists.php.net to get a copy of this message
Hi Lance: > class B > { > var $x = new A; > }; > > PHP 4 gives me a parse error when trying to initialize $x. Is there a way to > make PHP 4 work like it used to or must I move all object property > initializations to the class constructor? Yep, you'll have to do it in a constructor. Var's can only be set to strings or numbers. Setting it using a variable, function, math, etc are not legal. When I ran into this after converting from 3 to 4 it took me a LOOOOOONG time of hacking to track it down. Enjoy, --Dan -- PHP scripts that make your job easier http://www.analysisandsolutions.com/code/ SQL Solution | Layout Solution | Form Solution T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Ave, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409

« previous php.general (#27953) next »