Re: [PHP4BETA] Parse error with classes and requrires in php4

From: Date: Tue, 24 Aug 1999 14:52:13 +0000
Subject: Re: [PHP4BETA] Parse error with classes and requrires in php4
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-3678@lists.php.net to get a copy of this message
At 11:35 PM 8/23/99 -0600, David den Boer wrote:
I am having a problem (parse error at the var $dbHost line (or anything below) in the following code : <? require('../includes/php/mydb.inc'); require('../includes/php/configuration.inc'); class digitaldb extends mydb { var $dbHost = $theHost; var $dbName = $theDB; var $User = $theUser; var $Password = $thePassword; } ?> This code worked fine under php3, but not php4. It works if I statically assign variables, or give no assignment, but when assigning to variables from a required file, it causes a parse error. Can anyone help me with this? Thanks,
This is an incompatibility with PHP 3.0. Like in C++, in PHP 4.0 you can't use expressions to pre-initialize values. You could however, define theHost, theDB etc.. as constants and then use constants instead. For example: define("theHost", "foo.bar"); And then use var $dbHost = theHost; I'm pretty sure that will work. Andi --- Andi Gutmans <andi@zend.com> http://www.zend.com/

« previous php.version4 (#3678) next »