3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $lemon = 1; public function test($test, $cb) { return $cb(); } } $x = (new Foo())->test('hello', function (){ echo 'does this work? Lemon: ' . $this->lemon ; });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t7rT6
function name:  (null)
number of ops:  9
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        INIT_METHOD_CALL                                         $1, 'test'
          3        SEND_VAL_EX                                              'hello'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Ft7rT6%3A18%240'
   20     5        SEND_VAL_EX                                              ~3
          6        DO_FCALL                                      0  $4      
   18     7        ASSIGN                                                   !0, $4
   20     8      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Ft7rT6%3A18%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t7rT6
function name:  {closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_THIS                                       $0      
          1        FETCH_OBJ_R                                      ~1      $0, 'lemon'
          2        CONCAT                                           ~2      'does+this+work%3F+Lemon%3A+', ~1
          3        ECHO                                                     ~2
   20     4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Ft7rT6%3A18%240

Class Foo:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t7rT6
function name:  test
number of ops:  6
compiled vars:  !0 = $test, !1 = $cb
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        INIT_DYNAMIC_CALL                                        !1
          3        DO_FCALL                                      0  $2      
          4      > RETURN                                                   $2
   15     5*     > RETURN                                                   null

End of function test

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.97 ms | 1385 KiB | 13 Q