开发者

PHP - filename calls function on different script, get filename from script containing function

开发者 https://www.devze.com 2023-01-10 00:08 出处:网络
fileA.php: requires function.inc.php and uses x() from that include f开发者_如何学Cile fileB.php: requires fileA.php User invokes fileB.php to get fileA.php

fileA.php: requires function.inc.php and uses x() from that include f开发者_如何学Cile

fileB.php: requires fileA.php User invokes fileB.php to get fileA.php

function.inc.php: function x() - returns filename that invoked it

What is the PHP server variable or whatever that gets the name of fileA.php from within function.inc.php?

  • Usecase - function x() could be a mysql_query() or die(mail( {info about error as well as which file caused it} )

based on answer below - this works:

function x($q){ mysql_query($q) or die(mail('yourself@example.com,'error @ '.$_SERVER['PHP_SELF'] , serialize(debug_backtrace()) . "\n\n".mysql_error())); }


  • for the person who voted this down - could you provide a better idea/solution for the function trace above?


As far as I know there isn't one. You could traverse the output of debug_backtrace to find it.

0

精彩评论

暂无评论...
验证码 换一张
取 消