3v4l.org

run code in 300+ PHP versions simultaneously
<?php function makeClass($outer) { return eval( sprintf( 'return new class { public $inner = %s; };', var_export($outer, true) ) ); } var_dump(makeClass(42)); var_dump(makeClass(['Hello', 'World']));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sQaUS
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'makeclass'
          2        SEND_VAL                                                 42
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   15     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'makeclass'
          8        SEND_VAL                                                 <array>
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function makeclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sQaUS
function name:  makeClass
number of ops:  12
compiled vars:  !0 = $outer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'sprintf'
    6     2        SEND_VAL                                                 'return+new+class+%7B%0A++++++++++++++++public+%24inner+%3D+%25s%3B%0A++++++++++++%7D%3B'
    9     3        INIT_FCALL                                               'var_export'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $1      
          7        SEND_VAR                                                 $1
          8        DO_ICALL                                         $2      
          9        INCLUDE_OR_EVAL                                  $3      $2, EVAL
         10      > RETURN                                                   $3
   12    11*     > RETURN                                                   null

End of function makeclass

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.98 ms | 1398 KiB | 21 Q