3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { private $is_call = false; public function getFunc() { } public function run() { $this->is_call = true; $func = function($str) { if ($this->is_call) { echo $str; } }; $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/YDZlN
function name:  (null)
number of ops:  6
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   33     3        INIT_METHOD_CALL                                         !0, 'run'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FYDZlN%3A15%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/YDZlN
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        FETCH_THIS                                       $1      
          2        FETCH_OBJ_R                                      ~2      $1, 'is_call'
          3      > JMPZ                                                     ~2, ->5
   17     4    >   ECHO                                                     !0
   19     5    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FYDZlN%3A15%240

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

End of function run

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.36 ms | 1399 KiB | 13 Q