473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Checking variables in an include

Hi everybody,

could anybody explain the following phenomen :

I have this line in my project :

include
"http://".$domain."/help/".$language."/".$defaultIndex."/".$help.".php";

This construct properly includes the file I need to. And the included
file contains the following line :

echo $domain;

- and on this place comes nothing: obviously, the variable '$domain' is
not set for the <help.php>.

Why ?

Regards

Victor

Oct 6 '06 #1
5 1202
On 6 Oct 2006 15:30:18 -0700, "Victor" <bi******@chefmail.dewrote:
>could anybody explain the following phenomen :

I have this line in my project :

include
"http://".$domain."/help/".$language."/".$defaultIndex."/".$help.".php";

This construct properly includes the file I need to. And the included
file contains the following line :

echo $domain;

- and on this place comes nothing: obviously, the variable '$domain' is
not set for the <help.php>.

Why ?
How are you expecting it to be set? You're (almost certainly) executing the
remote PHP file in a totally different context - all you're include()ing is the
output of the PHP file from the remote server.

The only way it could work is if the webserver you're calling returns the PHP
source verbatim, without processing it, in which case it's run in the same
context as the calling script.

Are you sure you want to be doing remote HTTP includes? Including from the
filesystem is by far the more common usage, and is more likely to behave how
you expect.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Oct 6 '06 #2
How are you expecting it to be set? You're (almost certainly) executing the
remote PHP file in a totally different context - all you're include()ing is the
output of the PHP file from the remote server.

The only way it could work is if the webserver you're calling returns the PHP
source verbatim, without processing it, in which case it's run in the same
context as the calling script.

Are you sure you want to be doing remote HTTP includes? Including from the
filesystem is by far the more common usage, and is more likely to behave how
you expect.
You see, the file I am including is not a remote one. It sits in my
project directory. I agree, it might be not the best way to do
includes, but this way it is easier for me, because I use rather many
of them, calling them from different sublevels of the directory. And
the file that makes the described include is also not the one that has
set the variable $domain, but already 4th or something like this in the
hierarchy of includes. Nevertheless, it sees the variable and
constructs a correct name of the next include.
Suddenly, this following include does not see the $domain any more...

Victor

Oct 6 '06 #3
On 6 Oct 2006 15:44:44 -0700, "Victor" <bi******@chefmail.dewrote:
> Are you sure you want to be doing remote HTTP includes? Including from the
filesystem is by far the more common usage, and is more likely to behave how
you expect.
You see, the file I am including is not a remote one. It sits in my
project directory.
So include it through the filesystem. By using an HTTP URL you are doing
something completely different; reading the output of a completely separate
instance of PHP.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Oct 6 '06 #4

Thanks Andy!

I believe you have right... I'll try it and then report the result.

Victor

Oct 6 '06 #5
Yes, it works!

Thank you once again Andy!

Victor

Oct 7 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paris_Sucks | last post by:
I'm trying to redirect when testing for certain condidtions as shown below. When the conditions are ture, it redirects, but still goes ahead and processes the sql query. What am I doing wrong??? ...
23
by: Mark Parnell | last post by:
I'm relatively new to PHP, and have just converted a site from ASP to PHP. There is one thing I haven't managed to do, though. When the site was using ASP, I had one file (called variables.asp),...
3
by: Guy Robinson | last post by:
I have the code below which parses an expression string and creates tokens. Can anyone suggest the best of error checking for things like: Valid variable only obj.attribute -whitespace allowed...
5
by: Tongu? Yumruk | last post by:
I have a little proposal about type checking in python. I'll be glad if you read and comment on it. Sorry for my bad english (I'm not a native English speaker) A Little Stricter Typing in Python...
4
by: Martin | last post by:
I have some classes with statics public variables.... the problem is that the gcc compiles fine the files but in the linking process gcc says "multiple definitions of MyClass::Variable" or...
5
by: Timo | last post by:
I am having a problem with some preprocessor constant value checking: header.h: #define MY_CONSTANT 1 file.c #if MY_CONSTANTTT == 1 // <- note the typo!! // dostuff...
6
by: RoSsIaCrIiLoIA | last post by:
Do you know how to write a self-checking program in standard C? Do I can think that if I write in a file.c static g="1234567"; in the file.exe (or file) there is in some place...
8
by: Ian Pilcher | last post by:
When adding two values of type time_t, how can I check for overflow? Maybe I'm just brain-cramped today, but I can't figure out how to do it. Thanks! --...
6
by: Chris Carlen | last post by:
Hi: I have an embedded system, platform: TI TMS320F2812 32-bit integer DSP. A module (.c file) contains external (to the funcs in that module) variables which are used to affect the operation...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.