Reply to Re: 'nested conditional' that can identify parent page?

Your name:

Reply:


Posted by Norman Peelman on 05/14/07 02:42

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().
>

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

[Back to original 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

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