You are here: Re: 'nested conditional' that can identify parent page? « PHP Programming Language « IT news, forums, messages
Re: 'nested conditional' that can identify parent page?

Posted by Jerry Stuckle on 05/14/07 14:50

Alan Jones wrote:
> On Sun, 13 May 2007 09:41:17 -0500, Jerry Stuckle
> <jstucklex@attglobal.net> wrote:
>
>> 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.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация