Re: include

From: Date: Tue, 04 Feb 2003 19:36:42 +0000
Subject: Re: include
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-134317@lists.php.net to get a copy of this message
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.
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.

« previous php.general (#134317) next »