how to get file name from which current executing file is invoked???

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

    how to get file name from which current executing file is invoked???

    hi

    how can i get the file name from which the current executing file is
    called.
    i m making a scrript which will be called from many other scripts.
    this script performs some calculation and then returns the result to
    the script who asked for. so i want to know the script name of caller
    script in the current executing script

    thxs for your help in advance.

  • Daniel Tryba

    #2
    Re: how to get file name from which current executing file is invoked???

    vishal <vishal_panjabi @yahoo.co.in> wrote:[color=blue]
    > how can i get the file name from which the current executing file is
    > called.[/color]

    Dump phpinfo(32) and you'll probably see the info you are looking for.
    [color=blue]
    > i m making a scrript which will be called from many other scripts.
    > this script performs some calculation and then returns the result to
    > the script who asked for. so i want to know the script name of caller
    > script in the current executing script[/color]

    I don't get it. Why do you need to know the caller? If you
    include/require the "script library" return value/output will get back
    to the caller automatically.

    Comment

    • [-= Chris =-]

      #3
      Re: how to get file name from which current executing file is invoked???

      On 30 Mar 2005 12:49:43 GMT, Daniel Tryba
      <partmapsswen@i nvalid.tryba.nl > wrote:
      [color=blue]
      >vishal <vishal_panjabi @yahoo.co.in> wrote:[color=green]
      >> how can i get the file name from which the current executing file is
      >> called.[/color]
      >
      >Dump phpinfo(32) and you'll probably see the info you are looking for.
      >[color=green]
      >> i m making a scrript which will be called from many other scripts.
      >> this script performs some calculation and then returns the result to
      >> the script who asked for. so i want to know the script name of caller
      >> script in the current executing script[/color]
      >
      >I don't get it. Why do you need to know the caller? If you
      >include/require the "script library" return value/output will get back
      >to the caller automatically.[/color]

      I agree, I'd make the called file an include/require, but if this is
      not possible for whatever reason then you should be able to do
      something with $_SERVER["HTTP_REFER ER"] and extract the name of the
      calling file from that.




      Comment

      • Daniel Tryba

        #4
        Re: how to get file name from which current executing file is invoked???

        [-= Chris =-] <Chris.Stephens @nez.oc.ku> wrote:[color=blue][color=green]
        >>I don't get it. Why do you need to know the caller? If you
        >>include/require the "script library" return value/output will get back
        >>to the caller automatically.[/color]
        >
        > I agree, I'd make the called file an include/require, but if this is
        > not possible for whatever reason then you should be able to do
        > something with $_SERVER["HTTP_REFER ER"] and extract the name of the
        > calling file from that.[/color]

        Will in that case I would add an extra form element/get paramter/header
        to the request to tell the script who called it. referrer is totally
        unreliable.

        Comment

        • Chung Leong

          #5
          Re: how to get file name from which current executing file is invoked???

          "vishal" <vishal_panjabi @yahoo.co.in> wrote in message
          news:1112186008 .097507.177990@ f14g2000cwb.goo glegroups.com.. .[color=blue]
          > hi
          >
          > how can i get the file name from which the current executing file is
          > called.
          > i m making a scrript which will be called from many other scripts.
          > this script performs some calculation and then returns the result to
          > the script who asked for. so i want to know the script name of caller
          > script in the current executing script
          >
          > thxs for your help in advance.
          >[/color]

          debug_backtrace () will give you the info. In general though, it's not a good
          practice to use includes in lieu of functions. Better to wrap the code in a
          function, and have the calling code pass a parameter explicitly stating the
          required behavior/results.


          Comment

          • Tex John

            #6
            Re: how to get file name from which current executing file is invoked???

            Lots of these:

            echo "<!-- page = $page -->";
            or
            echo "<!-- function showForm -->";

            Low tech but works in a pinch if you are outputting to html.

            John


            "Daniel Tryba" <partmapsswen@i nvalid.tryba.nl > wrote in message
            news:424aaf25$0 $147$c5fe704e@n ews6.xs4all.nl. ..[color=blue]
            > [-= Chris =-] <Chris.Stephens @nez.oc.ku> wrote:[color=green][color=darkred]
            > >>I don't get it. Why do you need to know the caller? If you
            > >>include/require the "script library" return value/output will get back
            > >>to the caller automatically.[/color]
            > >
            > > I agree, I'd make the called file an include/require, but if this is
            > > not possible for whatever reason then you should be able to do
            > > something with $_SERVER["HTTP_REFER ER"] and extract the name of the
            > > calling file from that.[/color]
            >
            > Will in that case I would add an extra form element/get paramter/header
            > to the request to tell the script who called it. referrer is totally
            > unreliable.
            >[/color]


            Comment

            • R. Rajesh Jeba Anbiah

              #7
              Re: how to get file name from which current executing file is invoked???

              vishal wrote:
              <snip>[color=blue]
              > so i want to know the script name of caller
              > script in the current executing script[/color]

              __FILE__

              --
              <?php echo 'Just another PHP saint'; ?>
              Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

              Comment

              Working...