Re: [PROPOSAL] Payment_Process

From: Date: Sun, 14 Dec 2003 04:35:12 +0000
Subject: Re: [PROPOSAL] Payment_Process
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-24400@lists.php.net to get a copy of this message
In order for the constructor to fire you need to add parenthesis to your assignment: class foo { var $bar; function foo() { echo "Initializing variables ..."; $bar = 'I was here'; } } $class = & new foo(); // <-- notice ()'s echo $class->bar; I thought the declaration was deprecated as well, but I see it in PEAR all the time and I use it without incident in my own code. --Joe > On Saturday 13 December 2003 06:50 pm, Joe Stump wrote: >> Quick note ... >> >> You should just put the following declaration into the variable >> declaration at the top of the class: >> > Yeah... For some reason, I was under the impresson that PHP didn't allow > that. > The docs say: > > "In PHP 4, only constant initializers for var variables are allowed. To > initialize variables with non-constant values, you need an initialization > function which is called automatically when an object is being constructed > from the class. Such a function is called a constructor (see below)." > > But I just tried it, and it seems to work. It's been changed. > > -- > PEAR Development Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Joe Stump <joe@joestump.net> http://www.joestump.net "Label makers are proof God wants Sys Admins to be happy."

« previous php.pear.dev (#24400) next »