On Tue, 4 Feb 2003, Bob Lockie wrote:

> On 02/04/03 13:16 Philip Olson spoke thusly
> 
> > On Tue, 4 Feb 2003, Bob Lockie wrote:
> > 
> > 
> >>I don't appear to be able to use this variable in an include directive 
> >>because the variable is empty:
> >>include "$_SERVER['DOCUMENT_ROOT']
> >>
> >>Do I have the syntax incorrect?
> > 
> > 
> > Please post the exact syntax as you did not as the
> > above will provide a serious parse error.


> include "$_SERVER['DOCUMENT_ROOT']/visit_db.php";
> I am using 4.3.0, there is no release later.

  Then according to my post, this will not work and
  is affected by the mentioned bug.  So, rewrite it.

  Regards,
  Philip


> > To test
> > if a value exists, do:
> > 
> >   var_dump($_SERVER['DOCUMENT_ROOT']);
> > 
> > Or phpinfo().  Now, going off a guess, try:
> > 
> >   include $_SERVER['DOCUMENT_ROOT'] . '/foo.php';
> > 
> > The following will NOT work in 4.3.0 as there
> > is a bug when using the following syntax:
> > 
> >   echo "$_SERVER['DOCUMENT_ROOT']";
> >   echo "Er, $iam['inastringand'] buggy in 4.3.0";
> > 
> > Note that the above gives a parse error in 4.2.3,
> > a bogus E_NOTICE error in 4.3.0, and will work (no
> > parse error) in 4.3.1.  Now, the following always 
> > works:
> > 
> >   echo "{$_SERVER['DOCUMENT_ROOT']}";
> >   echo "So {$i['willalwayswork']} yeah!";
> > 
> > Note: We are specifically talking about using arrays
> > within strings where the array key is quoted.
> > 
> > Regards,
> > Philip
> > 
> > P.s. Autoglobals, such a $_SERVER, became available in
> > PHP in PHP 4.1.0
> > 
> > 
> 
> 
> -- 
> ----------------------------------------
> Sent from Mozilla and GNU/Linux.
> Powered by an AMD processor.
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to