Re: Logic behind this?
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Fri, 07 Jan 2011 12:13:11 -0500
On 1/7/2011 9:17 AM, Modafanil wrote:
"Modafanil"<invalid@xxxxxxxxx> wrote in message
I tried to include one PHP file from within another one that is running on
Without the query string the inclusion works fine. Add the query string,
however, and the server refuses with 'can't find a matching file or
Wouldn't PHP be a more consistent language if it were possible to pass
query strings during file inclusion, and then be able to access the
parameters as maybe $_SERVER['QUERY_STRING'] or $_GET['message'] within
the included file?
I'd be interested to hear from anyone that can rationalise the current
file inclusion functions' behavior.
Okay, I've had a good look at the PHP manual as suggested, and my needs
appear less complex than originally thought. It seems I can customise the
behavior of local included scripts, and pass them parameters, simply by
setting some variable values. Variables that are in scope within the parent
script at the point of child inclusion, are also visible in the outer-most
division of scope within the included PHP script. I set $message = 'this'
and then include the sub-script, and can then read $message anywhere outside
of functions in the included file.
That then solves the question of why PHP doesn't support passing query
strings to files included from a local filesystem. There's simply no need.
Including either local or remote PHP script files with a HTTP request looks
interesting. It appears that any query string pairs that you append to the
inclusion URI, become available as local variables within the included
script. That makes sense, as the $_GET and $_SERVER superglobals are then
preserved, and not clobbered by any sub-script inclusion.
I'm a little confused about how inclusion of remotely located PHP scripts
works, though. I can't seem to grasp which machine the script runs on? I
could do with a few pointers here, as I couldn't seem to follow the manual's
PHP scripts run on the server, so if you request a PHP script from another server, it will run on the remote. You will get only the output from that script, just as if you were to request it from a browser.
But rather than set variables before including the script, check out functions and passing parameters to them. It makes your code much more maintainable and reliable.
Remove the "x" from my email address
JDS Computer Training Corp.
- Re: Logic behind this?
- From: Modafinil
- Re: Logic behind this?