3v4l.org

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

Function %00%7Bclosure%7D%2Fin%2FBZvje%3A8%240:
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/BZvje
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $str, !1 = $enable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    9     2        FETCH_THIS                                       $2      
          3        FETCH_OBJ_R                                      ~3      $2, 'is_call'
          4      > JMPZ                                                     ~3, ->6
   10     5    >   ECHO                                                     !0
   12     6    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FBZvje%3A8%240

Class Test:
Function getfunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BZvje
function name:  getFunc
number of ops:  4
compiled vars:  !0 = $enable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBZvje%3A8%240'
          1        BIND_LEXICAL                                             ~1, !0
   12     2      > RETURN                                                   ~1
   13     3*     > 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/BZvje
function name:  run
number of ops:  18
compiled vars:  !0 = $func
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_METHOD_CALL                                         'getFunc'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   18     3        INIT_DYNAMIC_CALL                                        !0
          4        SEND_VAL_EX                                              'ok'
          5        DO_FCALL                                      0          
   20     6        ECHO                                                     '%0A---------------%0A'
   22     7        ASSIGN_OBJ                                               'is_call'
          8        OP_DATA                                                  <false>
   23     9        INIT_DYNAMIC_CALL                                        !0
         10        SEND_VAL_EX                                              'not+ok'
         11        DO_FCALL                                      0          
   25    12        ASSIGN_OBJ                                               'is_call'
         13        OP_DATA                                                  <true>
   26    14        INIT_DYNAMIC_CALL                                        !0
         15        SEND_VAL_EX                                              '--ok--'
         16        DO_FCALL                                      0          
   27    17      > RETURN                                                   null

End of function run

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
187.11 ms | 1403 KiB | 13 Q