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

Function %00%7Bclosure%7D%2Fin%2FQfsLd%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QfsLd
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%2FQfsLd%3A4%240

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

End of function %00%7Bclosure%7D%2Fin%2FQfsLd%3A14%241

Function %00%7Bclosure%7D%2Fin%2FQfsLd%3A20%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QfsLd
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $arg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     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%2FQfsLd%3A20%242

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

End of function __construct

End of class Bla.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
255.16 ms | 1399 KiB | 14 Q