Skip to content

Instantly share code, notes, and snippets.

@tivnet
Created May 19, 2016 03:45
Show Gist options
  • Save tivnet/2b9eb5a65bb9a096eaea984c004e1686 to your computer and use it in GitHub Desktop.
Save tivnet/2b9eb5a65bb9a096eaea984c004e1686 to your computer and use it in GitHub Desktop.
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