3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Simple math class class Math { function __construct($a) { $this->a =$a; } //Returns a closure function mul() { //We can't directly use $this inside closure $self = $this; return function($n) { return $n*$this->a; }; } } $math = new Math(5); $mul = $math->mul(); echo $mul(4); //Output : 20 ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jDLTj
function name:  (null)
number of ops:  12
compiled vars:  !0 = $math, !1 = $mul
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $2      'Math'
          1        SEND_VAL_EX                                              5
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   19     4        INIT_METHOD_CALL                                         !0, 'mul'
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
   20     7        INIT_DYNAMIC_CALL                                        !1
          8        SEND_VAL_EX                                              4
          9        DO_FCALL                                      0  $7      
         10        ECHO                                                     $7
   21    11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FjDLTj%3A13%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jDLTj
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        FETCH_THIS                                       $1      
          2        FETCH_OBJ_R                                      ~2      $1, 'a'
          3        MUL                                              ~3      !0, ~2
          4      > RETURN                                                   ~3
   15     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FjDLTj%3A13%240

Class Math:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jDLTj
function name:  __construct
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        ASSIGN_OBJ                                               'a'
          2        OP_DATA                                                  !0
    7     3      > RETURN                                                   null

End of function __construct

Function mul:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jDLTj
function name:  mul
number of ops:  5
compiled vars:  !0 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_THIS                                       ~1      
          1        ASSIGN                                                   !0, ~1
   13     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FjDLTj%3A13%240'
   15     3      > RETURN                                                   ~3
   16     4*     > RETURN                                                   null

End of function mul

End of class Math.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.63 ms | 1395 KiB | 13 Q