Is it possible to call a function inside the same function without specifying the function name - for example using some magic keyword?
Yes. The constant __FUNCTION__ gives the string representation of the current function. ( src )
__FUNCTION__
function testMe() { print __FUNCTION__; } testMe(); // outputs "testMe"
You can of course use this to call yourself:
$func = __FUNCTION__; $func();
function someFunction($i) { $method = __FUNCTION__; if ( $i > 0 ) { return $method($i-1); } return $i; }
a simple example of recursion, not knowing the function name, will call itself for $i -times if $i positive.
$i