Re: [PHP4BETA] Using $GLOBALS array in an object
| From: | Zeev Suraski | Date: | Fri, 21 Apr 2000 09:26:59 +0000 |
| Subject: | Re: [PHP4BETA] Using $GLOBALS array in an object | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-13869@lists.php.net to get a copy of this message | ||
$var = new Object;
is equivalent to
$var = new Object();
On Fri, 21 Apr 2000, Bob Silva wrote:
> Is the constructor behavior different also? Meaning if I add a constructor
> to all my classes, will I also need to modify all my current code thats like
> this: $var = new Object; to $var = new Object(); Or is it implied?
>
> Thanks for the fast answer Zeev.
>
> Salty``
>
> ----- Original Message -----
> From: "Zeev Suraski" <zeev@zend.com>
> To: "Bob Silva" <bsilva@umesd.k12.or.us>
> Cc: <php4beta@lists.php.net>
> Sent: Friday, April 21, 2000 2:11 AM
> Subject: Re: [PHP4BETA] Using $GLOBALS array in an object
>
>
> > 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/
> >
> >
>
--
Zeev Suraski <zeev@zend.com>
http://www.zend.com/