Get Current Script File Name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • thehuby

    Get Current Script File Name

    How do you get the name of the currently execting script?

    By this I mean the name of the include file that is being executed:

    File: include.php
    <?php
    //Call some function to display include.php or whatever my filename is
    ?>

    File: holder.php
    <?php
    inlcude( "include.ph p" );
    ?>

    I tried everything in the $_SERVER variable but to no avail - Googling
    it doesn't help as it all points to either the include method or the
    $_SERVER variable. These all just give me 'holder.php' or similar.

    I want this as I want to create a LOGGER class similar to the one in
    Java to catch errors and keep them logged in a file I can download from
    time to time.

  • Chung Leong

    #2
    Re: Get Current Script File Name

    __FILE__

    Comment

    • Cristian

      #3
      Re: Get Current Script File Name

      1. use __FILE__

      2. You don't need to code a new Logger Class, PEAR Log package can suit
      your needs.

      Comment

      • leo

        #4
        Re: Get Current Script File Name


        "thehuby" <thehuby@gmail. com> wrote in message
        news:1146091551 .632293.167980@ v46g2000cwv.goo glegroups.com.. .[color=blue]
        > How do you get the name of the currently execting script?
        >
        > By this I mean the name of the include file that is being executed:
        >
        > File: include.php
        > <?php
        > //Call some function to display include.php or whatever my filename is
        > ?>
        >
        > File: holder.php
        > <?php
        > inlcude( "include.ph p" );
        > ?>
        >
        > I tried everything in the $_SERVER variable but to no avail - Googling
        > it doesn't help as it all points to either the include method or the
        > $_SERVER variable. These all just give me 'holder.php' or similar.
        >[/color]

        what is the output of $_SERVER['PHP_SELF']?

        what is your php version?


        Comment

        • Colin McKinnon

          #5
          Re: Get Current Script File Name

          leo wrote:
          [color=blue]
          >
          > "thehuby" <thehuby@gmail. com> wrote in message
          > news:1146091551 .632293.167980@ v46g2000cwv.goo glegroups.com.. .[color=green]
          >> How do you get the name of the currently execting script?
          >>[/color]
          >
          > what is the output of $_SERVER['PHP_SELF']?
          >[/color]

          Not what he is looking for.

          1) it does not account for included files
          2) Apache can be tricked into putting different values in here (try Google
          for more info).

          C.

          Comment

          Working...