Created
May 19, 2016 03:45
-
-
Save tivnet/2b9eb5a65bb9a096eaea984c004e1686 to your computer and use it in GitHub Desktop.
Demonstration of debug_backtrace change in PHP 7.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Demonstration of debug_backtrace change in PHP 7. | |
* | |
* `call_user_func` and `call_user_func_array` do not appear as separate calls in the trace. | |
* | |
* @author Gregory Karpinsky (@tivnet) | |
*/ | |
main(); | |
function main() { | |
call_user_func( 'secondary' ); | |
} | |
function secondary() { | |
$dbt = debug_backtrace(); | |
$level = 2; | |
if ( version_compare( PHP_VERSION, '7.0.0', '>=' ) ) { | |
$level --; | |
} | |
echo PHP_VERSION . ': ' . $dbt[ $level ]['function'] . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment