Re: [PHP4BETA] Using $GLOBALS array in an object

From: Date: Fri, 21 Apr 2000 09:11:04 +0000
Subject: Re: [PHP4BETA] Using $GLOBALS array in an object
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-13863@lists.php.net to get a copy of this message
On Fri, 21 Apr 2000, Bob Silva wrote: > In one master include file at the top outside any objects I have: > > $CACHE_ROOT = "/cache"; > > then inside an object later in the same page I have: > > Line 370: var $CACHE_DIR = $GLOBALS["CACHE_ROOT"]; > > This is giving a parse error: > Parse error: parse error in libBravenet.php on line 370 > > I have a very similar line where I am setting a class var to a GLOBALS > variable and it dies there as well. > This code has worked fine in PHP3 for ages, so I cant figure out whats going > on. > > I do have the optimizer installed, but even disabling that didnt help. > Any ideas? The optimizer doesn't affect the parsing engine, or the behavior of PHP in general, except for making it run faster. As of PHP 4.0, initialization values (for static members, class members or default function arguments) have to be static (i.e. numbers, static strings or static array()'s). In order to initialize your cache dir, you must move the initialization to the class's constructor. Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/

« previous php.version4 (#13863) next »