Vincent DUPONT wrote: > hi > > I'm afraid this is not available by default. > You can try to parse the debug_backtrace() (see http://be2.php.net/manual/en/function.debug-backtrace.php) > but this is probably too complex for online processing. unless you are doing something *very* exotic (which almost by definition means your skills are beyond the point whereby this list could probably help you) there should be *no* reason for a function to ever need to know who/what/where it was called from/by ... of course in the process of developing something like debug_backtrace() can be very handy for helping to figure out what is going on! that said if a function seems to need to know who called it (or anything like that) then you probably have a bad smell in your design .. consider that a function does something according to it's input, and that the output of a function should be predictable [given a particular set of input parameters) then the caller, it's environment/start and/or the execution path should have no baring on the function's result - if they did then the function's result could no longer be considered predictable (unless your going to memorize every execution-path/state in your application now and in the future!). having said all that there are probably some exceptions to the rule - although I can't think of any right now. > > if there are some native functions, please tell me !! there are none - although I did read a thread on the internals mailing list that mentioned something along these lines in the form of a request ... unlikely that it will be included. > > > Vincent Dupont > Principal Consultant OpenSource Competence Center > Ausy Belgium > http://www.ausy.be > > > > -----Original Message----- > From: clive [mailto:clive@xxxxxxxxxx] > Sent: Mon 2/26/2007 15:15 > To: clive > Cc: PHP General List > Subject: Re: $_SERVER['PHP_SELF'] in a included file > > Thanks Vincent,Stut and Olaf. Thats __file___ is exactly what I needed :) > > now for another brain teaser for your collective brains, How does a > function know what file it was called from. > > a.php includes functions.php > > in a.php we call function test(); which is declared in functions.php > > Is there anyway for test(); to echo "called from a.php" with out > passing 'a.php' or ___FILE___ as a parameter to the function? > > Im busy googling now for a answer. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php