3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (!defined('PHP_INT_MAX')) { $min = -1; do { $last = $min; } while(0 > $min <<= 1); define('PHP_INT_MIN', $last); define('PHP_INT_MAX', ~$last); } class Foo { function getBacktrace($firstLevel = 0, $count = PHP_INT_MAX) { $result = array(); foreach (array_slice(debug_backtrace(), 1 + $firstLevel) as $level) { var_dump($level); } } function bar() { $this->getBacktrace(); } function baz() { Foo::getBacktrace(); } } $a = new Foo; $a->bar(); Foo::baz();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 1, Position 2 = 15
Branch analysis from position: 1
2 jumps found. (Code = 44) Position 1 = 6, Position 2 = 2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
Branch analysis from position: 15
filename:       /in/cSjVJ
function name:  (null)
number of ops:  23
compiled vars:  !0 = $min, !1 = $last, !2 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E > > JMPZ                                                     <false>, ->15
    4     1    >   ASSIGN                                                   !0, -1
    6     2    >   ASSIGN                                                   !1, !0
    7     3        ASSIGN_OP                                     6  ~5      !0, 1
          4        IS_SMALLER                                               ~5, 0
          5      > JMPNZ                                                    ~6, ->2
    9     6    >   INIT_FCALL                                               'define'
          7        SEND_VAL                                                 'PHP_INT_MIN'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
   10    10        INIT_FCALL                                               'define'
         11        SEND_VAL                                                 'PHP_INT_MAX'
         12        BW_NOT                                           ~8      !1
         13        SEND_VAL                                                 ~8
         14        DO_ICALL                                                 
   31    15    >   NEW                                              $10     'Foo'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !2, $10
   32    18        INIT_METHOD_CALL                                         !2, 'bar'
         19        DO_FCALL                                      0          
   33    20        INIT_STATIC_METHOD_CALL                                  'Foo', 'baz'
         21        DO_FCALL                                      0          
         22      > RETURN                                                   1

Class Foo:
Function getbacktrace:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/cSjVJ
function name:  getBacktrace
number of ops:  18
compiled vars:  !0 = $firstLevel, !1 = $count, !2 = $result, !3 = $level
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV_INIT                                        !0      0
          1        RECV_INIT                                        !1      <const ast>
   16     2        ASSIGN                                                   !2, <array>
   17     3        INIT_FCALL                                               'array_slice'
          4        INIT_FCALL                                               'debug_backtrace'
          5        DO_ICALL                                         $5      
          6        SEND_VAR                                                 $5
          7        ADD                                              ~6      1, !0
          8        SEND_VAL                                                 ~6
          9        DO_ICALL                                         $7      
         10      > FE_RESET_R                                       $8      $7, ->16
         11    > > FE_FETCH_R                                               $8, !3, ->16
   18    12    >   INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !3
         14        DO_ICALL                                                 
   17    15      > JMP                                                      ->11
         16    >   FE_FREE                                                  $8
   20    17      > RETURN                                                   null

End of function getbacktrace

Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cSjVJ
function name:  bar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_METHOD_CALL                                         'getBacktrace'
          1        DO_FCALL                                      0          
   24     2      > RETURN                                                   null

End of function bar

Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cSjVJ
function name:  baz
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_STATIC_METHOD_CALL                                  'Foo', 'getBacktrace'
          1        DO_FCALL                                      0          
   28     2      > RETURN                                                   null

End of function baz

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.43 ms | 1400 KiB | 21 Q