|
Posted by shimmyshack on 05/13/07 11:47
On May 13, 4:47 am, Alan Jones <a...@jalanjones.com> wrote:
> On Sat, 12 May 2007 23:24:25 -0400, Norman Peelman
>
> <npeel...@cfl.rr.com> wrote:
> > I'm sorry, maybe I don't understand what you're asking for...
>
> No sorry needed. :)
>
> >doesn't $_SERVER['REQUEST_URI'] do what you need?
>
> >if (($_SERVER['REQUEST_URI'] == '/index.php') ||
> >($_SERVER['REQUEST_URI'] == '/'))
> >{
> > include('signature.php');
> >}
>
> >I found that $_SERVER['REQUEST_URI'] will return '/' at the top of the
> >domain name. In other words '/' should be equal to whatever your default
> >file is for the domain in question.
>
> >Norm
>
> http://www.php.net/manual/en/reserved.variables.php#reserved.variable...>
>
> I went thru the above page last night and the most promising
> did seem 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 the request was called from,
> the include 'child' file, and not the resulting page URL address;
> /index.php. I need the include script to know if it is being run
> from 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 me understand
> '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 I have no idea what version of php you are running, but
REQUEST_URI is the value of the intially requested URI, unless you are
playing around with things using apache rewrites that will have the
script_name at the end - if you have typed it otherwise it might
have /
an included file is just that, it gets included within the "parent"
script, forming one big load of code, it does not in any way at all
have an identity related to the request_uri which is passed to php
from the server.
To find the name of the included file therefore in a large block of
code some of which was the parent and some the include, the only way
is to ask php what file it had to open, so
echo __FILE__ always returns the name of the file that the echo
statement is in, whether parent or include.
this is because php knows which file it is looking at.
php however hasnt got a clue what the request_uri is, until apache
tells it, it is fixed and has nothing to do with included files or
even the parent file.
Navigation:
[Reply to this message]
|