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() { $this->is_call = true; $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/VSHBJ
function name:  (null)
number of ops:  6
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   32     3        INIT_METHOD_CALL                                         !0, 'run'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FVSHBJ%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/VSHBJ
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%2FVSHBJ%3A8%240

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

End of function run

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.18 ms | 1399 KiB | 13 Q