3v4l.org

run code in 300+ PHP versions simultaneously
<?php $obj = new StdClass; $obj->fn = function($arg) { return "Hello $arg"; }; echo ($obj->fn)('World'); class Bla { public $fn; public $fn2; public function __construct(){ $this->fn2 = function(){ echo "F!"; }; } } $bla = new Bla; $bla->fn = function($arg="Bu"){return "Hello lo $arg"; }; // can't do in class! echo ($bla->fn)('Wa'); $blah = new Bla(); ($bla->fn2)();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPOhK
function name:  (null)
number of ops:  29
compiled vars:  !0 = $obj, !1 = $bla, !2 = $blah
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $3      'StdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
    4     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FLPOhK%3A4%240'
          4        ASSIGN_OBJ                                               !0, 'fn'
          5        OP_DATA                                                  ~7
    5     6        FETCH_OBJ_R                                      ~8      !0, 'fn'
          7        INIT_DYNAMIC_CALL                                        ~8
          8        SEND_VAL_EX                                              'World'
          9        DO_FCALL                                      0  $9      
         10        ECHO                                                     $9
   17    11        NEW                                              $10     'Bla'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !1, $10
   18    14        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FLPOhK%3A18%242'
         15        ASSIGN_OBJ                                               !1, 'fn'
         16        OP_DATA                                                  ~14
   19    17        FETCH_OBJ_R                                      ~15     !1, 'fn'
         18        INIT_DYNAMIC_CALL                                        ~15
         19        SEND_VAL_EX                                              'Wa'
         20        DO_FCALL                                      0  $16     
         21        ECHO                                                     $16
   21    22        NEW                                              $17     'Bla'
         23        DO_FCALL                                      0          
         24        ASSIGN                                                   !2, $17
   22    25        FETCH_OBJ_R                                      ~20     !1, 'fn2'
         26        INIT_DYNAMIC_CALL                                        ~20
         27        DO_FCALL                                      0          
         28      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FLPOhK%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPOhK
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $arg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        NOP                                                      
          2        FAST_CONCAT                                      ~1      'Hello+', !0
          3      > RETURN                                                   ~1
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FLPOhK%3A4%240

Function %00%7Bclosure%7D%2Fin%2FLPOhK%3A12%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPOhK
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ECHO                                                     'F%21'
   14     1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FLPOhK%3A12%241

Function %00%7Bclosure%7D%2Fin%2FLPOhK%3A18%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPOhK
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $arg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV_INIT                                        !0      'Bu'
          1        NOP                                                      
          2        FAST_CONCAT                                      ~1      'Hello+lo+', !0
          3      > RETURN                                                   ~1
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FLPOhK%3A18%242

Class Bla:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LPOhK
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FLPOhK%3A12%241'
          1        ASSIGN_OBJ                                               'fn2'
   14     2        OP_DATA                                                  ~1
   15     3      > RETURN                                                   null

End of function __construct

End of class Bla.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.67 ms | 1399 KiB | 13 Q