471,596 Members | 919 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,596 software developers and data experts.

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.

Jul 17 '05 #1
6 3929
vishal <vi************@yahoo.co.in> wrote:
how can i get the file name from which the current executing file is
called.
Dump phpinfo(32) and you'll probably see the info you are looking for.
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


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.

Jul 17 '05 #2
On 30 Mar 2005 12:49:43 GMT, Daniel Tryba
<pa**********@invalid.tryba.nl> wrote:
vishal <vi************@yahoo.co.in> wrote:
how can i get the file name from which the current executing file is
called.


Dump phpinfo(32) and you'll probably see the info you are looking for.
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


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.


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_REFERER"] and extract the name of the
calling file from that.


Jul 17 '05 #3
[-= Chris =-] <Ch************@nez.oc.ku> wrote:
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.


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_REFERER"] and extract the name of the
calling file from that.


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.

Jul 17 '05 #4
"vishal" <vi************@yahoo.co.in> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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.


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.
Jul 17 '05 #5
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" <pa**********@invalid.tryba.nl> wrote in message
news:42*********************@news6.xs4all.nl...
[-= Chris =-] <Ch************@nez.oc.ku> wrote:
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.


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_REFERER"] and extract the name of the
calling file from that.


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.

Jul 17 '05 #6
vishal wrote:
<snip>
so i want to know the script name of caller
script in the current executing script


__FILE__

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

Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

33 posts views Thread by Jacek Generowicz | last post: by
2 posts views Thread by Suresh Gladstone | last post: by
5 posts views Thread by Eugene Anthony | last post: by
4 posts views Thread by rsaharia | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.