Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Demonstration of debug_backtrace change in PHP 7.
<?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