Is there a way to get the function name of a PHP function from
within an include file included by that function? I know you can
use a global variable to pass the value of __FUNCTION__, but
that defeats the purpose of what I am trying to achieve.
Basicly, what I'm looking for is a PHP function/code that I can
place in my include file *only* that says, "execute __FUNCTION__
within the scope of the calling function and return the results to this
scope". Is there anything like that in Php?
Here's a small example that illustrates what I am trying to achieve:
Include file testinc.php:
<?php
function xxxtestit () {
global $temp;
$temp = "<P>This works!</P>\r\n";
}
$func = 'xxx'.__FUNCTION__;
if (function_exists($func))
$func();
?>
File testit.php:
<?php
function displayit () {
global $temp;
header ("Content-type: text/html");
echo
"<html>\r\n<head>\r\n<title>Testit</title>\r\n</head>\r\n<body>\r\n$temp</body>\r\n</html>";
}
function testit () {
global $temp;
$temp = "<P>This doesn't work because of the scope of
'__FUNCTION__'.</P>\r\n";
include("testinc.php");
displayit();
}
$temp='';
testit();
?>
>> Stay informed about: Getting function name from within include