3v4l.org

run code in 500+ 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:  11
compiled vars:  !0 = $outer
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    9     1        INIT_FCALL                                                   'var_export'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     <true>
          4        DO_ICALL                                             $1      
          5        ROPE_INIT                                         3  ~3      'return+new+class+%7B%0A++++++++++++++++public+%24inner+%3D+'
          6        ROPE_ADD                                          1  ~3      ~3, $1
          7        ROPE_END                                          2  ~2      ~3, '%3B%0A++++++++++++%7D%3B'
          8        INCLUDE_OR_EVAL                                      $5      ~2, EVAL
          9      > RETURN                                                       $5
   12    10*     > RETURN                                                       null

End of function makeclass

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
191.47 ms | 1740 KiB | 17 Q