By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,838 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

'nested conditional' that can identify parent page?

P: n/a

Hello everyone, any help would be greatly appreciated. :)

What I'm trying to do may not be advisable, but here goes...

I want a page named signature.php to appear conditionally as
an include within another include so that it will, for example,
appear in index.php but not in other result pages that use the
same top level include.

The method would need to determine what page it is inside of
during each given instance. I guess something like...

if page is index.php then include file else do nothing

A 'nested conditional' seems obvious but I don't know how to
create an argument that checks the result page file name or
otherwise id's that parent page.

Obviously, I'm new to PHP and my understanding of basic
programming is very limited. I'm also new to the group. I hope
to learn quickly, and I look forward to helping others in the
future.
May 11 '07 #1
Share this Question
Share on Google+
16 Replies


P: n/a
fel
On 11 mayo, 17:42, Alan Jones <a...@jalanjones.comwrote:
Hello everyone, any help would be greatly appreciated. :)

What I'm trying to do may not be advisable, but here goes...

I want a page named signature.php to appear conditionally as
an include within another include so that it will, for example,
appear in index.php but not in other result pages that use the
same top level include.

The method would need to determine what page it is inside of
during each given instance. I guess something like...

if page is index.php then include file else do nothing

A 'nested conditional' seems obvious but I don't know how to
create an argument that checks the result page file name or
otherwise id's that parent page.

Obviously, I'm new to PHP and my understanding of basic
programming is very limited. I'm also new to the group. I hope
to learn quickly, and I look forward to helping others in the
future.

use debug_backtrace() ?

May 11 '07 #2

P: n/a
On May 11, 6:42 pm, Alan Jones <a...@jalanjones.comwrote:
Hello everyone, any help would be greatly appreciated. :)

What I'm trying to do may not be advisable, but here goes...

I want a page named signature.php to appear conditionally as
an include within another include so that it will, for example,
appear in index.php but not in other result pages that use the
same top level include.

The method would need to determine what page it is inside of
during each given instance. I guess something like...

if page is index.php then include file else do nothing

A 'nested conditional' seems obvious but I don't know how to
create an argument that checks the result page file name or
otherwise id's that parent page.

Obviously, I'm new to PHP and my understanding of basic
programming is very limited. I'm also new to the group. I hope
to learn quickly, and I look forward to helping others in the
future.
You can always find out what the "top-level" script is with
$_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME'] then base your
decision to include on that.

<http://www.php.net/manual/en/
reserved.variables.php#reserved.variables.server>

However, if you want to include something on one page only why
wouldn't you just include it on that page? For example, if you want
to include "common.php" on every page and "signature.php" on index.php
only, why not just put the following on index.php:

include('common.php');
include('signature.php');

instead of putting signature.php inside common.php under some
condition?

May 11 '07 #3

P: n/a
On 11 May 2007 15:59:55 -0700, fel <fe**********@gmail.comwrote:
>On 11 mayo, 17:42, Alan Jones <a...@jalanjones.comwrote:
>Hello everyone, any help would be greatly appreciated. :)

What I'm trying to do may not be advisable, but here goes...

I want a page named signature.php to appear conditionally as
an include within another include so that it will, for example,
appear in index.php but not in other result pages that use the
same top level include.

The method would need to determine what page it is inside of
during each given instance. I guess something like...

if page is index.php then include file else do nothing

A 'nested conditional' seems obvious but I don't know how to
create an argument that checks the result page file name or
otherwise id's that parent page.

Obviously, I'm new to PHP and my understanding of basic
programming is very limited. I'm also new to the group. I hope
to learn quickly, and I look forward to helping others in the
future.


use debug_backtrace() ?
Thank you for the quick response. I'll check that out and report
back any success.

I was thinking something so simple as declaring a string in the
parent page and getting a conditional statement within the first
include to see it, act on it's presence; decide whether to process
the second include. Shirley this can be done :D
May 11 '07 #4

P: n/a
On 11 May 2007 16:47:16 -0700, ZeldorBlat <ze********@gmail.com>
wrote:
>On May 11, 6:42 pm, Alan Jones <a...@jalanjones.comwrote:
>Hello everyone, any help would be greatly appreciated. :)

What I'm trying to do may not be advisable, but here goes...

I want a page named signature.php to appear conditionally as
an include within another include so that it will, for example,
appear in index.php but not in other result pages that use the
same top level include.

The method would need to determine what page it is inside of
during each given instance. I guess something like...

if page is index.php then include file else do nothing

A 'nested conditional' seems obvious but I don't know how to
create an argument that checks the result page file name or
otherwise id's that parent page.

Obviously, I'm new to PHP and my understanding of basic
programming is very limited. I'm also new to the group. I hope
to learn quickly, and I look forward to helping others in the
future.

You can always find out what the "top-level" script is with
$_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME'] then base your
decision to include on that.

<http://www.php.net/manual/en/
reserved.variables.php#reserved.variables.serve r>
I think that may be my answer. :) Thank you, I'll need to read up
on it a bit and do some testing.
>However, if you want to include something on one page only why
wouldn't you just include it on that page? For example, if you want
to include "common.php" on every page and "signature.php" on index.php
only, why not just put the following on index.php:

include('common.php');
include('signature.php');

instead of putting signature.php inside common.php under some
condition?
My proposed solution is probably overkill. My original problem is
positioning of the content. All of the content in the first include
is within a table.

In the parent page, I could create the table structure of the first
include, break the first include into parts, and populate the cells
individually with the pieces and parts of the first and second
include. My problem with that is I want to retain the ability to
work with, edit, the first include as a single page.

In the parent page, maybe there is a way to specify the position/
location of one include inside another?

May 12 '07 #5

P: n/a
On May 11, 8:36 pm, Alan Jones <a...@jalanjones.comwrote:
On 11 May 2007 16:47:16 -0700, ZeldorBlat <zeldorb...@gmail.com>
wrote:
On May 11, 6:42 pm, Alan Jones <a...@jalanjones.comwrote:
Hello everyone, any help would be greatly appreciated. :)
What I'm trying to do may not be advisable, but here goes...
I want a page named signature.php to appear conditionally as
an include within another include so that it will, for example,
appear in index.php but not in other result pages that use the
same top level include.
The method would need to determine what page it is inside of
during each given instance. I guess something like...
if page is index.php then include file else do nothing
A 'nested conditional' seems obvious but I don't know how to
create an argument that checks the result page file name or
otherwise id's that parent page.
Obviously, I'm new to PHP and my understanding of basic
programming is very limited. I'm also new to the group. I hope
to learn quickly, and I look forward to helping others in the
future.
You can always find out what the "top-level" script is with
$_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_NAME'] then base your
decision to include on that.
<http://www.php.net/manual/en/
reserved.variables.php#reserved.variables.server>

I think that may be my answer. :) Thank you, I'll need to read up
on it a bit and do some testing.
However, if you want to include something on one page only why
wouldn't you just include it on that page? For example, if you want
to include "common.php" on every page and "signature.php" on index.php
only, why not just put the following on index.php:
include('common.php');
include('signature.php');
instead of putting signature.php inside common.php under some
condition?

My proposed solution is probably overkill. My original problem is
positioning of the content. All of the content in the first include
is within a table.

In the parent page, I could create the table structure of the first
include, break the first include into parts, and populate the cells
individually with the pieces and parts of the first and second
include. My problem with that is I want to retain the ability to
work with, edit, the first include as a single page.

In the parent page, maybe there is a way to specify the position/
location of one include inside another?
What I would do in that case is define a variable or constant in your
top (index) page before including common.php, then check for it before
including signature.php. That way you aren't limited to only showing
it on index.php, but can instead pick and choose which pages to
include it on.

So, in your index.php (or any other page on which you want to show
the "signature") you would do something like this:

define('SHOW_SIGNATURE', true);
include('common.php');

Then, common.php might look something like this:

//output some HTML
if(defined('SHOW_SIGNATURE') && SHOW_SIGNATURE)
include('signature.php')
//output some more HTML

That's basically the same as checking the value of
$_SERVER['SCRIPT_NAME'] but it gives you a bit more flexibility.

May 12 '07 #6

P: n/a
On 11 May 2007 17:46:48 -0700, ZeldorBlat <ze********@gmail.com>
wrote:
>My proposed solution is probably overkill. My original problem is
positioning of the content. All of the content in the first include
is within a table.

In the parent page, I could create the table structure of the first
include, break the first include into parts, and populate the cells
individually with the pieces and parts of the first and second
include. My problem with that is I want to retain the ability to
work with, edit, the first include as a single page.

In the parent page, maybe there is a way to specify the position/
location of one include inside another?

What I would do in that case is define a variable or constant in your
top (index) page before including common.php, then check for it before
including signature.php. That way you aren't limited to only showing
it on index.php, but can instead pick and choose which pages to
include it on.

So, in your index.php (or any other page on which you want to show
the "signature") you would do something like this:

define('SHOW_SIGNATURE', true);
include('common.php');
First of all, thank you very much for clueing me in on this area of
programming. Without your help, I would still be very lost, but is
there a way to make basename, or a similar function, simply return
the filename of the parent page; the page the include is in? Thanks
again, I really appreciate any help I can get.

May 12 '07 #7

P: n/a
On May 12, 7:35 pm, Alan Jones <a...@jalanjones.comwrote:
On 11 May 2007 17:46:48 -0700, ZeldorBlat <zeldorb...@gmail.com>
wrote:
My proposed solution is probably overkill. My original problem is
positioning of the content. All of the content in the first include
is within a table.
In the parent page, I could create the table structure of the first
include, break the first include into parts, and populate the cells
individually with the pieces and parts of the first and second
include. My problem with that is I want to retain the ability to
work with, edit, the first include as a single page.
In the parent page, maybe there is a way to specify the position/
location of one include inside another?
What I would do in that case is define a variable or constant in your
top (index) page before including common.php, then check for it before
including signature.php. That way you aren't limited to only showing
it on index.php, but can instead pick and choose which pages to
include it on.
So, in your index.php (or any other page on which you want to show
the "signature") you would do something like this:
define('SHOW_SIGNATURE', true);
include('common.php');

First of all, thank you very much for clueing me in on this area of
programming. Without your help, I would still be very lost, but is
there a way to make basename, or a similar function, simply return
the filename of the parent page; the page the include is in? Thanks
again, I really appreciate any help I can get.
Yes -- look at the following URL:

<http://www.php.net/manual/en/
reserved.variables.php#reserved.variables.server>

and try the various variables available to see what they return.

May 13 '07 #8

P: n/a
On 12 May 2007 19:51:19 -0700, ZeldorBlat <ze********@gmail.com>
wrote:
>First of all, thank you very much for clueing me in on this area of
programming. Without your help, I would still be very lost, but is
there a way to make basename, or a similar function, simply return
the filename of the parent page; the page the include is in? Thanks
again, I really appreciate any help I can get.

Yes -- look at the following URL:

<http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server>

and try the various variables available to see what they return.
I went thru that page last night and the most promising seemed to
be 'REQUEST_URI', which is supposed to output, "The URI which was
given in order to access this page; for instance, '/index.html'."

However, both...

echo ($_SERVER['REQUEST_URI']);

and...

echo basename($_SERVER['REQUEST_URI']);

....returned the name of the file it is in, the include 'child' file,
and not the actual page URL accessed; /index.php. I need the
include script to know if it is being run within index.php.

Again, thanks for racking your brain on this with me. I'm at a
total loss... :(

BTW, might you or anyone be able to help with understanding
'open_basedir restriction'? I received the following error when
trying to use the link() function...

link ("/index.php","/index_body.php");

Warning: link(): open_basedir restriction in effect.
File(/index.php) is not within the allowed path(s):
(/home/httpd/vhosts/jalanjones.com/httpdocs:/tmp) in
/home/httpd/vhosts/jalanjones.com/httpdocs/index_body.php on line 46

Thanks :)
May 13 '07 #9

P: n/a
At Sun, 13 May 2007 03:26:41 +0000, Alan Jones let his monkeys type:
On 12 May 2007 19:51:19 -0700, ZeldorBlat <ze********@gmail.com>
wrote:

[snip]

I went thru that page last night and the most promising seemed to
be 'REQUEST_URI', which is supposed to output, "The URI which was
given in order to access this page; for instance, '/index.html'."

However, both...

echo ($_SERVER['REQUEST_URI']);

and...

echo basename($_SERVER['REQUEST_URI']);

...returned the name of the file it is in, the include 'child' file,
and not the actual page URL accessed; /index.php. I need the
include script to know if it is being run within index.php.
It _should_ tell you the top level calling script. Show us what you
are doing exactly please. Btw, I am no fan of include files behaving
differently depending on where they're called from. What if your script
name changes ?
BTW, might you or anyone be able to help with understanding
'open_basedir restriction'? I received the following error when trying
to use the link() function...

link ("/index.php","/index_body.php");
Open_basedir is a php setting telling the server the top_level directory
from which files can be opened in your scripts. It's commonly set to point
to your httpdocs dir. (In php.ini)
You got this warning because you tried linking files from your server's
root directory. Link takes a filepath, not a url. In other words, remove
the / from the arguments. (Or provide a full path to the file):

link ("index.php","index_body.php");

Using the phpinfo() function you can see if open_basedir is set and if so,
to what directory.

HTH
Sh.

May 13 '07 #10

P: n/a
Alan Jones wrote:
On 12 May 2007 19:51:19 -0700, ZeldorBlat <ze********@gmail.com>
wrote:
>>First of all, thank you very much for clueing me in on this area of
programming. Without your help, I would still be very lost, but is
there a way to make basename, or a similar function, simply return
the filename of the parent page; the page the include is in? Thanks
again, I really appreciate any help I can get.
Yes -- look at the following URL:

<http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server>

and try the various variables available to see what they return.

I went thru that page last night and the most promising seemed to
be 'REQUEST_URI', which is supposed to output, "The URI which was
given in order to access this page; for instance, '/index.html'."

However, both...

echo ($_SERVER['REQUEST_URI']);

and...

echo basename($_SERVER['REQUEST_URI']);

...returned the name of the file it is in, the include 'child' file,
and not the actual page URL accessed; /index.php. I need the
include script to know if it is being run within index.php.

Again, thanks for racking your brain on this with me. I'm at a
total loss... :(

BTW, might you or anyone be able to help with understanding
'open_basedir restriction'? I received the following error when
trying to use the link() function...

link ("/index.php","/index_body.php");

Warning: link(): open_basedir restriction in effect.
File(/index.php) is not within the allowed path(s):
(/home/httpd/vhosts/jalanjones.com/httpdocs:/tmp) in
/home/httpd/vhosts/jalanjones.com/httpdocs/index_body.php on line 46

Thanks :)
Alan,

$_SERVER['REQUEST_URI'] does give the uri used to fetch the page. I'm
not sure what you mean by 'child' file. Are you using frames? Maybe if
you post the code you're using (including that in the 'parent' and
'child' pages) it will be more clear.

And as Schraalhans indicated, commands which relate to the underlying
filesystem (i.e. link, fopen, include, etc.) reference the file system
directly. So if you use absolute paths (beginning with '/'), it is the
root directory of the file system. But your host has limited you so all
you can access are files in /hom/httpd/vhosts/jalanjones.com/httpdocs
and /tmp.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 13 '07 #11

P: n/a
On Sun, 13 May 2007 09:44:20 +0200, Schraalhans Keukenmeester
<in*****@invalid.spamwrote:
>echo ($_SERVER['REQUEST_URI']);

and...

echo basename($_SERVER['REQUEST_URI']);

...returned the name of the file it is in, the include 'child' file,
and not the actual page URL accessed; /index.php. I need the
include script to know if it is being run within index.php.

It _should_ tell you the top level calling script. Show us what you
are doing exactly please.
Thanks for the help. Please see my response to Jerry's post. Just
want to consolidate the thread. :)
>Btw, I am no fan of include files behaving
differently depending on where they're called from. What if your script
name changes ?
I hope to get the request_uri result working correctly for now, and
then compose a script simple enough to not cause future problems.
>Open_basedir is a php setting telling the server the top_level directory
from which files can be opened in your scripts. It's commonly set to point
to your httpdocs dir. (In php.ini)
You got this warning because you tried linking files from your server's
root directory. Link takes a filepath, not a url. In other words, remove
the / from the arguments. (Or provide a full path to the file):

link ("index.php","index_body.php");
Thanks, I'll put that aside for now. Hopefully, I won't need to use
link().
>Using the phpinfo() function you can see if open_basedir is set and if so,
to what directory.
Apparently it is: /home/httpd/vhosts/jalanjones.com/httpdocs:/tmp

I assume that's the correct setting.

May 13 '07 #12

P: n/a
On Sun, 13 May 2007 09:41:17 -0500, Jerry Stuckle
<js*******@attglobal.netwrote:
>Alan,

$_SERVER['REQUEST_URI'] does give the uri used to fetch the page. I'm
not sure what you mean by 'child' file. Are you using frames? Maybe if
you post the code you're using (including that in the 'parent' and
'child' pages) it will be more clear.
Thanks for helping me. :)

To isolate the process, I have recreated the scenario using new
files, file names, and a new folder called 'test'.

http://jalanjones.com/index2.php

: Inside of index2.php is...

<html><head><title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head><body>

<p>This sentence is in the index2.php file.</p>

<p><?php include('http://jalanjones.com/test/content.php');?></p>

<p>Why is there a numeral one (1) at the end? (scratching
head)<br><br></p>

</body></html>

: ...and inside of /test/content.php is...

<html><head><title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head><body>
<table cellpadding="10" style="border:1px solid #333333"><tr><td>

<p><br>This table is in the content.php 'include' file.</p>

<p>REQUEST_URI result:&nbsp;&nbsp;&nbsp;<b>
<?php echo($_SERVER['REQUEST_URI']);?></b></p>

<p>The result (/test/content.php) is the name of the include/child
file, not the parent page; the URL.</p>

<p>Below is phpinfo() run from inside the include file. Please see
the PHP Variables section...<br><br></p>

<?php echo phpinfo();?>

</table></tr></td>
</body></html>

Can anyone identify the culprit? Again, I am very new to PHP so it
is probably something only a clueless newb would do. :D
>And as Schraalhans indicated, commands which relate to the underlying
filesystem (i.e. link, fopen, include, etc.) reference the file system
directly. So if you use absolute paths (beginning with '/'), it is the
root directory of the file system. But your host has limited you so all
you can access are files in /hom/httpd/vhosts/jalanjones.com/httpdocs
and /tmp.
Thanks, I hope to avoid using link().

May 13 '07 #13

P: n/a
Alan Jones wrote:
On Sun, 13 May 2007 09:41:17 -0500, Jerry Stuckle
<js*******@attglobal.netwrote:
>Alan,

$_SERVER['REQUEST_URI'] does give the uri used to fetch the page. I'm
not sure what you mean by 'child' file. Are you using frames? Maybe if
you post the code you're using (including that in the 'parent' and
'child' pages) it will be more clear.

Thanks for helping me. :)

To isolate the process, I have recreated the scenario using new
files, file names, and a new folder called 'test'.

http://jalanjones.com/index2.php

: Inside of index2.php is...

<html><head><title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head><body>

<p>This sentence is in the index2.php file.</p>

<p><?php include('http://jalanjones.com/test/content.php');?></p>

<p>Why is there a numeral one (1) at the end? (scratching
head)<br><br></p>

</body></html>

: ...and inside of /test/content.php is...

<html><head><title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head><body>
<table cellpadding="10" style="border:1px solid #333333"><tr><td>

<p><br>This table is in the content.php 'include' file.</p>

<p>REQUEST_URI result:&nbsp;&nbsp;&nbsp;<b>
<?php echo($_SERVER['REQUEST_URI']);?></b></p>

<p>The result (/test/content.php) is the name of the include/child
file, not the parent page; the URL.</p>

<p>Below is phpinfo() run from inside the include file. Please see
the PHP Variables section...<br><br></p>

<?php echo phpinfo();?>

</table></tr></td>
</body></html>

Can anyone identify the culprit? Again, I am very new to PHP so it
is probably something only a clueless newb would do. :D
>And as Schraalhans indicated, commands which relate to the underlying
filesystem (i.e. link, fopen, include, etc.) reference the file system
directly. So if you use absolute paths (beginning with '/'), it is the
root directory of the file system. But your host has limited you so all
you can access are files in /hom/httpd/vhosts/jalanjones.com/httpdocs
and /tmp.

Thanks, I hope to avoid using link().
I see what you mean... look at it this way... when retrieving a file
via HTTP:// the $_SERVER['REQUEST_URI'] will be set to the uri that
contains it. HINT: the -containing- uri. When retrieving from the
filesystem $_SERVER['REQUEST_URI'] is coming from the original page
therefor pointing to the right /index.php or whatever. It's like there
are two $_SERVER['REQUEST_URI'] variables but they don't collide.

example:

index.php
---
<?PHP
echo $_SERVER['REQUEST_URI'].'<br>';
include('http://insert.your.domain/page2.php'); // http transport
include('page2.php'); // filesystem
echo $_SERVER['REQUEST_URI'].'<br>';
?>

page2.php
---
<?PHP
echo $_SERVER['REQUEST_URI'].'<br>';
?>

---

will output:

/index.php
/page2.php
/index.php
/index.php

obviously your not after /page2.php


Norm

May 14 '07 #14

P: n/a
Alan Jones wrote:
On Sun, 13 May 2007 09:41:17 -0500, Jerry Stuckle
<js*******@attglobal.netwrote:
>Alan,

$_SERVER['REQUEST_URI'] does give the uri used to fetch the page. I'm
not sure what you mean by 'child' file. Are you using frames? Maybe if
you post the code you're using (including that in the 'parent' and
'child' pages) it will be more clear.

Thanks for helping me. :)

To isolate the process, I have recreated the scenario using new
files, file names, and a new folder called 'test'.

http://jalanjones.com/index2.php

: Inside of index2.php is...

<html><head><title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head><body>

<p>This sentence is in the index2.php file.</p>

<p><?php include('http://jalanjones.com/test/content.php');?></p>

<p>Why is there a numeral one (1) at the end? (scratching
head)<br><br></p>

</body></html>

: ...and inside of /test/content.php is...

<html><head><title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head><body>
<table cellpadding="10" style="border:1px solid #333333"><tr><td>

<p><br>This table is in the content.php 'include' file.</p>

<p>REQUEST_URI result:&nbsp;&nbsp;&nbsp;<b>
<?php echo($_SERVER['REQUEST_URI']);?></b></p>

<p>The result (/test/content.php) is the name of the include/child
file, not the parent page; the URL.</p>

<p>Below is phpinfo() run from inside the include file. Please see
the PHP Variables section...<br><br></p>

<?php echo phpinfo();?>

</table></tr></td>
</body></html>

Can anyone identify the culprit? Again, I am very new to PHP so it
is probably something only a clueless newb would do. :D
>And as Schraalhans indicated, commands which relate to the underlying
filesystem (i.e. link, fopen, include, etc.) reference the file system
directly. So if you use absolute paths (beginning with '/'), it is the
root directory of the file system. But your host has limited you so all
you can access are files in /hom/httpd/vhosts/jalanjones.com/httpdocs
and /tmp.

Thanks, I hope to avoid using link().
This is working normally. When you said:

<?php include('http://jalanjones.com/test/content.php');?>

This resulted in another call to the server to fetch test/content.php.
So the URL in there will be "test/content.php". The only difference
here is you included it from the server side instead of the client side
- but when the http: request reaches the server, the server neither
knows nor cares about the origin. The PHP file is executed and the
results returned to index2.php, where they are displayed.

Now, if you would have instead done something like:

<?php include($_SERVER['DOCUMENT_ROOT'] . '/test/content.php');?>

This would have gone directly to the file system and included the file
without an additional call to Apache. The file would have been
included, the code executed and the results displayed.

Do you see the difference between the two?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 14 '07 #15

P: n/a
On Sun, 13 May 2007 22:42:14 -0400, Norman Peelman
<np******@cfl.rr.comwrote:
I see what you mean... look at it this way... when retrieving a file
via HTTP:// the $_SERVER['REQUEST_URI'] will be set to the uri that
contains it. HINT: the -containing- uri. When retrieving from the
filesystem $_SERVER['REQUEST_URI'] is coming from the original page
therefor pointing to the right /index.php or whatever. It's like there
are two $_SERVER['REQUEST_URI'] variables but they don't collide.

example:

index.php
---
<?PHP
echo $_SERVER['REQUEST_URI'].'<br>';
include('http://insert.your.domain/page2.php'); // http transport
include('page2.php'); // filesystem
echo $_SERVER['REQUEST_URI'].'<br>';
?>

page2.php
---
<?PHP
echo $_SERVER['REQUEST_URI'].'<br>';
?>

---

will output:

/index.php
/page2.php
/index.php
/index.php

obviously your not after /page2.php

Norm
Shhhhh! (lol) I was waiting to see if the others here would figure
it out. :D Yes, as per my reply to shimmyshack in alt.php and you
in ACLP, using the file system path to make the include fixed the
problem.

Again, thanks, I'm now able to use the script you recommended.
I took out the || ($_SERVER['REQUEST_URI'] == '/') part. It didn't
end up being necessary. And, I'm using PHP_SELF instead of
REQUEST_URI...

if ($_SERVER['PHP_SELF'] == '/index.php'){include('signature.php');}

I am now a very happy coder/camper. :)
May 14 '07 #16

P: n/a
On Mon, 14 May 2007 10:50:46 -0400, Jerry Stuckle
<js*******@attglobal.netwrote:
>This is working normally. When you said:

<?php include('http://jalanjones.com/test/content.php');?>

This resulted in another call to the server to fetch test/content.php.
So the URL in there will be "test/content.php". The only difference
here is you included it from the server side instead of the client side
- but when the http: request reaches the server, the server neither
knows nor cares about the origin. The PHP file is executed and the
results returned to index2.php, where they are displayed.

Now, if you would have instead done something like:

<?php include($_SERVER['DOCUMENT_ROOT'] . '/test/content.php');?>

This would have gone directly to the file system and included the file
without an additional call to Apache. The file would have been
included, the code executed and the results displayed.

Do you see the difference between the two?
Yup, I get it now. I'm just going to use the file system paths for
now rather than spend more time doing experimentation in this
area. It's good to know using http paths is still an option, doable.

Thank you for the help. :) Everyone has been very helpful. I'm
saving each reply for future reference.
May 14 '07 #17

This discussion thread is closed

Replies have been disabled for this discussion.