l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
August 5: Social gathering
Next Installfest:
TBD
Latest News:
Jul. 4: July, August and September: Security, Photography and Programming for Kids
Page last updated:
2005 Feb 25 15:03

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] PHP Question: Includes and Variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] PHP Question: Includes and Variables



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
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.