3v4l.org

run code in 300+ PHP versions simultaneously
<?php // $a = new stdClass(); // $a->sum = function($a,$b){return $a + $b;}; // // var_dump($a->sum); // // echo ($a->sum)(3,5); // $b = (object)["sum" => function($a,$b){return $a + $b;}]; // var_dump(($b->sum)(1,2)); class A{ public $sum; function __construct(){ $this->sum = function($a, $b){ return $a + $b; }; } function __call($method,$args) { // var_dump($method,$args); return call_user_func_array($this->$method, $args); // var_dump($test,$this->$method); } } $a = new A(); var_dump($a->sum(1,2)); $a->sub = function($a, $b){ return $a- $b; }; var_dump($a->sub(10,5)); var_dump($a->multiply(10,5));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1veYm
function name:  (null)
number of ops:  28
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   NEW                                              $1      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   33     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'sum'
          5        SEND_VAL_EX                                              1
          6        SEND_VAL_EX                                              2
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
   35    10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F1veYm%3A35%241'
         11        ASSIGN_OBJ                                               !0, 'sub'
   37    12        OP_DATA                                                  ~7
   39    13        INIT_FCALL                                               'var_dump'
         14        INIT_METHOD_CALL                                         !0, 'sub'
         15        SEND_VAL_EX                                              10
         16        SEND_VAL_EX                                              5
         17        DO_FCALL                                      0  $8      
         18        SEND_VAR                                                 $8
         19        DO_ICALL                                                 
   40    20        INIT_FCALL                                               'var_dump'
         21        INIT_METHOD_CALL                                         !0, 'multiply'
         22        SEND_VAL_EX                                              10
         23        SEND_VAL_EX                                              5
         24        DO_FCALL                                      0  $10     
         25        SEND_VAR                                                 $10
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F1veYm%3A18%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1veYm
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        ADD                                              ~2      !0, !1
          3      > RETURN                                                   ~2
   20     4*     > RETURN                                                   null

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

Function %00%7Bclosure%7D%2Fin%2F1veYm%3A35%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1veYm
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   36     2        SUB                                              ~2      !0, !1
          3      > RETURN                                                   ~2
   37     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F1veYm%3A35%241

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1veYm
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F1veYm%3A18%240'
          1        ASSIGN_OBJ                                               'sum'
   20     2        OP_DATA                                                  ~1
   21     3      > RETURN                                                   null

End of function __construct

Function __call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1veYm
function name:  __call
number of ops:  9
compiled vars:  !0 = $method, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   26     2        FETCH_OBJ_R                                      ~2      !0
          3        INIT_USER_CALL                                0          'call_user_func_array', ~2
          4        SEND_ARRAY                                               !1
          5        CHECK_UNDEF_ARGS                                         
          6        DO_FCALL                                      0  $3      
          7      > RETURN                                                   $3
   28     8*     > RETURN                                                   null

End of function __call

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.51 ms | 1400 KiB | 15 Q