3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test1($unset = false) { static $bar = 0; $bar++; echo $bar; if ($unset) { unset($bar); } } function test2($unset = false) { global $bar; if (!isset($bar)) { $bar = 0; } $bar++; echo $bar; if ($unset) { unset($bar); } } test1(); test1(); test1(true); test1(); echo "\n"; test2(); test2(); test2(true); test2();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bAfb5
function name:  (null)
number of ops:  20
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'test1'
          1        DO_FCALL                                      0          
   32     2        INIT_FCALL                                               'test1'
          3        DO_FCALL                                      0          
   33     4        INIT_FCALL                                               'test1'
          5        SEND_VAL                                                 <true>
          6        DO_FCALL                                      0          
   34     7        INIT_FCALL                                               'test1'
          8        DO_FCALL                                      0          
   35     9        ECHO                                                     '%0A'
   36    10        INIT_FCALL                                               'test2'
         11        DO_FCALL                                      0          
   37    12        INIT_FCALL                                               'test2'
         13        DO_FCALL                                      0          
   38    14        INIT_FCALL                                               'test2'
         15        SEND_VAL                                                 <true>
         16        DO_FCALL                                      0          
   39    17        INIT_FCALL                                               'test2'
         18        DO_FCALL                                      0          
         19      > RETURN                                                   1

Function test1:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/bAfb5
function name:  test1
number of ops:  7
compiled vars:  !0 = $unset, !1 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      <false>
    4     1        BIND_STATIC                                              !1
    6     2        PRE_INC                                                  !1
    8     3        ECHO                                                     !1
   10     4      > JMPZ                                                     !0, ->6
   11     5    >   UNSET_CV                                                 !1
   13     6    > > RETURN                                                   null

End of function test1

Function test2:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
Branch analysis from position: 6
filename:       /in/bAfb5
function name:  test2
number of ops:  11
compiled vars:  !0 = $unset, !1 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV_INIT                                        !0      <false>
   16     1        BIND_GLOBAL                                              !1, 'bar'
   17     2        ISSET_ISEMPTY_CV                                 ~2      !1
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->6
   18     5    >   ASSIGN                                                   !1, 0
   21     6    >   PRE_INC                                                  !1
   23     7        ECHO                                                     !1
   25     8      > JMPZ                                                     !0, ->10
   26     9    >   UNSET_CV                                                 !1
   28    10    > > RETURN                                                   null

End of function test2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.99 ms | 1392 KiB | 17 Q