3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Custom { public $sum = NULL; function __construct() { $this->sum = function ($a, $b) {return $a + $b;}; } } $cl = new stdClass; $cl->sum = function ($a, $b) {return $a + $b;}; $custom = new Custom(); echo ($custom->sum)(44, 44); echo ($cl->sum)(33, 33);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ZqNV
function name:  (null)
number of ops:  22
compiled vars:  !0 = $cl, !1 = $custom
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   NEW                                              $2      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   12     3        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
          4        ASSIGN_OBJ                                               !0, 'sum'
          5        OP_DATA                                                  ~6
   13     6        NEW                                              $7      'Custom'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $7
   15     9        FETCH_OBJ_R                                      ~10     !1, 'sum'
         10        INIT_DYNAMIC_CALL                                        ~10
         11        SEND_VAL_EX                                              44
         12        SEND_VAL_EX                                              44
         13        DO_FCALL                                      0  $11     
         14        ECHO                                                     $11
   16    15        FETCH_OBJ_R                                      ~12     !0, 'sum'
         16        INIT_DYNAMIC_CALL                                        ~12
         17        SEND_VAL_EX                                              33
         18        SEND_VAL_EX                                              33
         19        DO_FCALL                                      0  $13     
         20        ECHO                                                     $13
         21      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ZqNV
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        ADD                                              ~2      !0, !1
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of Dynamic Function 0

Class Custom:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ZqNV
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          1        ASSIGN_OBJ                                               'sum'
          2        OP_DATA                                                  ~1
    8     3      > RETURN                                                   null


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

End of Dynamic Function 0

End of function __construct

End of class Custom.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
251.63 ms | 1004 KiB | 13 Q