3v4l.org

run code in 300+ PHP versions simultaneously
<?php function anon() { static $i = 0; return eval(sprintf('return new class { public $prop%s; };', ++$i)); } $c1 = anon(); $c1->prop1 = 'hello'; $c2 = anon(); var_dump($c1, $c2, $c1->prop1, $c1->prop2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Eq3Di
function name:  (null)
number of ops:  17
compiled vars:  !0 = $c1, !1 = $c2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'anon'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   10     3        ASSIGN_OBJ                                               !0, 'prop1'
          4        OP_DATA                                                  'hello'
   11     5        INIT_FCALL                                               'anon'
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !1, $5
   13     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        FETCH_OBJ_R                                      ~7      !0, 'prop1'
         12        SEND_VAL                                                 ~7
         13        FETCH_OBJ_R                                      ~8      !0, 'prop2'
         14        SEND_VAL                                                 ~8
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function anon:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Eq3Di
function name:  anon
number of ops:  9
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   BIND_STATIC                                              !0
    6     1        INIT_FCALL                                               'sprintf'
          2        SEND_VAL                                                 'return+new+class+%7B+public+%24prop%25s%3B+%7D%3B'
          3        PRE_INC                                          ~1      !0
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6        INCLUDE_OR_EVAL                                  $3      $2, EVAL
          7      > RETURN                                                   $3
    7     8*     > RETURN                                                   null

End of function anon

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.28 ms | 1001 KiB | 17 Q