Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #5058

Re: Name of page itself?

From Scott Johnson <noonehome@chalupasworld.com>
Newsgroups comp.lang.php
Subject Re: Name of page itself?
Date 2012-03-01 06:02 -0800
Organization A noiseless patient Spider
Message-ID <jinvi3$3ra$1@dont-email.me> (permalink)
References <29234465-827c-4372-9dc7-d9322fb4703e@m2g2000vbc.googlegroups.com> <M6SdnYuS6JcvRtHSnZ2dnUVZ_t-dnZ2d@cablespeedmi.com>

Show all headers | View raw


On 2/28/2012 5:50 AM, bill wrote:
> On 2/28/2012 4:58 AM, Sonnich Jensen wrote:
>> Hi
>>
>> I have not worked with PHP for 2+ years, now again and need to refill
>> my brain...
>>
>> How can I get the name of the main page?
>>
>> Say, index.php includes menu.php, how do I get the name of the main
>> page, in this case index.php?
>> Next say page1.php, page2.php etc?
>>
>> Sonnich
>
> I use: basename(__FILE__)

Actually __FILE__ may not give you the results you expect all depending 
on where it is processed.

It will hold the value of the actual page where it is located which 
could not be the actual page being displayed but in a script called by 
the display page.

This would be common for display page to have an included file which 
lets say has a link back to the itself.  Using __FILE__ on the 
processing page will then link it to the actual processing page rather 
then the display page.  In this case using $_SERVER vars mentioned 
earlier would give predictable results (again depending on the server, 
for instance my dev box does not return URI but the production box does) 
but I do believe 'PHP_SELF' is more predictable.

Now a very good use for __FILE__ would be error routines/messages along 
with __LINE__ and others to help report errors on an actual script page.

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Name of page itself? Sonnich Jensen <sonnichjensen@gmail.com> - 2012-02-28 01:58 -0800
  Re: Name of page itself? tdk2fe <tdkrupinski@gmail.com> - 2012-02-28 02:14 -0800
  Re: Name of page itself? crankypuss <no@email.thanks> - 2012-02-28 03:23 -0700
  Re: Name of page itself? bill <nobody@spamcop.net> - 2012-02-28 08:50 -0500
    Re: Name of page itself? Scott Johnson <noonehome@chalupasworld.com> - 2012-03-01 06:02 -0800
  Re: Name of page itself? Captain Paralytic <paul_lautman@yahoo.com> - 2012-03-01 03:16 -0800
    Re: Name of page itself? Tim Streater <timstreater@greenbee.net> - 2012-03-01 12:15 +0000
      Re: Name of page itself? The Natural Philosopher <tnp@invalid.invalid> - 2012-03-01 12:57 +0000
        Re: Name of page itself? Paul Herber <paul@pherber.com> - 2012-03-01 13:54 +0000
          Re: Name of page itself? Paul Herber <paul@pherber.com> - 2012-03-01 13:59 +0000
          Re: Name of page itself? The Natural Philosopher <tnp@invalid.invalid> - 2012-03-01 14:06 +0000
          Re: Name of page itself? Jerry Stuckle <jstucklex@attglobal.net> - 2012-03-01 10:05 -0500
        Re: Name of page itself? Scott Johnson <noonehome@chalupasworld.com> - 2012-03-01 06:04 -0800
          Re: Name of page itself? The Natural Philosopher <tnp@invalid.invalid> - 2012-03-01 14:10 +0000
            Re: Name of page itself? Tim Streater <timstreater@greenbee.net> - 2012-03-01 17:05 +0000
            Re: Name of page itself? Scott Johnson <noonehome@chalupasworld.com> - 2012-03-01 15:28 -0800
        Re: Name of page itself? Tim Streater <timstreater@greenbee.net> - 2012-03-01 17:01 +0000
        Re: Name of page itself? Arno Welzel <usenet@arnowelzel.de> - 2012-03-02 18:31 +0100
  Re: Name of page itself? "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2012-03-01 13:01 +0100
  Re: Name of page itself? Denis McMahon <denismfmcmahon@gmail.com> - 2012-03-01 15:23 +0000

csiph-web