3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function getFunc($turn) { static $enable = false; $enable = $turn; return function($str) use ($enable) { if ($enable) { echo $str; } }; } public function run() { $func = $this->getFunc(true); $func('ok'); echo PHP_EOL.'---------------'.PHP_EOL; $this->getFunc(false); $func('not ok'); } } $test = new Test(); $test->run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8BrPY
function name:  (null)
number of ops:  6
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   29     3        INIT_METHOD_CALL                                         !0, 'run'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F8BrPY%3A9%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
filename:       /in/8BrPY
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $str, !1 = $enable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   10     2      > JMPZ                                                     !1, ->4
   11     3    >   ECHO                                                     !0
   13     4    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F8BrPY%3A9%240

Class Test:
Function getfunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8BrPY
function name:  getFunc
number of ops:  7
compiled vars:  !0 = $turn, !1 = $enable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        BIND_STATIC                                              !1
    7     2        ASSIGN                                                   !1, !0
    9     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8BrPY%3A9%240'
          4        BIND_LEXICAL                                             ~3, !1
   13     5      > RETURN                                                   ~3
   14     6*     > RETURN                                                   null

End of function getfunc

Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8BrPY
function name:  run
number of ops:  15
compiled vars:  !0 = $func
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_METHOD_CALL                                         'getFunc'
          1        SEND_VAL_EX                                              <true>
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   19     4        INIT_DYNAMIC_CALL                                        !0
          5        SEND_VAL_EX                                              'ok'
          6        DO_FCALL                                      0          
   21     7        ECHO                                                     '%0A---------------%0A'
   23     8        INIT_METHOD_CALL                                         'getFunc'
          9        SEND_VAL_EX                                              <false>
         10        DO_FCALL                                      0          
   24    11        INIT_DYNAMIC_CALL                                        !0
         12        SEND_VAL_EX                                              'not+ok'
         13        DO_FCALL                                      0          
   25    14      > RETURN                                                   null

End of function run

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.05 ms | 1390 KiB | 13 Q