[vox-tech] PHP Question: Includes and Variables

Richard S. Crawford rscrawford at mossroot.com
Fri Feb 25 15:03:02 PST 2005


Bill Kendrick said:
> On Fri, Feb 25, 2005 at 01:41:31PM -0800, Richard S. Crawford wrote:
>> Here's the situation.
>>
>> My script, page1.php, calls a script in another directory called
>> config.php via require_once.  config.php declares several variables
>> which
>> should be accessible in page1.php.  For example:
>
> Just to make sure, neither the "require_once" nor the "echo" are inside
> your own PHP functions, are they?

Nope.

But I found the problem.  Deep in the heart of some of the more obscure
documentation on php.net, I found this:

"Please don't forget: values of included (or required) file variables are
NOT available in the local script if the included file resides on a remote
server."

So even though the include file was on the same server as the main script,
I was calling it via a URL, so the PHP processor was looking at it as an
HTTP request, so the variables inside the include script were not
available to my main script.  I changed the require_once call to reference
the include file by absolute path instead of by URL, and it works now.

-- 
Sláinte,
Richard S. Crawford (AIM: Buffalo2K)
http://www.mossroot.com   http://www.stonegoose.com/catseyeview
"We live as though the world were how it should be,
to show it what it can be."
--"Angel", Season 4 ep. 1


More information about the vox-tech mailing list