3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test($test) { return new class($test) { public function __construct(public $test) {} }; } function test3($test) { return eval("return new class($test) { public function __construct(public \$test) {}};" ); } function compare($a, $b) { var_dump([ $a == $b, $a === $b, get_class($a) == get_class($b), ]); } compare(test(1), test(1)); // true, false, true, compare(test3(1), test3(1)); // false, false, false,
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LZLdZ
function name:  (null)
number of ops:  21
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'compare'
          1        INIT_FCALL                                               'test'
          2        SEND_VAL                                                 1
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        INIT_FCALL                                               'test'
          6        SEND_VAL                                                 1
          7        DO_FCALL                                      0  $1      
          8        SEND_VAR                                                 $1
          9        DO_FCALL                                      0          
   24    10        INIT_FCALL                                               'compare'
         11        INIT_FCALL                                               'test3'
         12        SEND_VAL                                                 1
         13        DO_FCALL                                      0  $3      
         14        SEND_VAR                                                 $3
         15        INIT_FCALL                                               'test3'
         16        SEND_VAL                                                 1
         17        DO_FCALL                                      0  $4      
         18        SEND_VAR                                                 $4
         19        DO_FCALL                                      0          
         20      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LZLdZ
function name:  test
number of ops:  7
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        DECLARE_ANON_CLASS                               <unknown> 
          2        NEW                                              $2      $1
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $2
    7     6*     > RETURN                                                   null

End of function test

Function test3:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LZLdZ
function name:  test3
number of ops:  7
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        ROPE_INIT                                     3  ~2      'return+new+class%28'
          2        ROPE_ADD                                      1  ~2      ~2, !0
          3        ROPE_END                                      2  ~1      ~2, '%29+%7B%0A++++++++public+function+__construct%28public+%24test%29+%7B%7D%7D%3B'
          4        INCLUDE_OR_EVAL                                  $4      ~1, EVAL
          5      > RETURN                                                   $4
   12     6*     > RETURN                                                   null

End of function test3

Function compare:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LZLdZ
function name:  compare
number of ops:  14
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        INIT_FCALL                                               'var_dump'
   16     3        IS_EQUAL                                         ~2      !0, !1
          4        INIT_ARRAY                                       ~3      ~2
   17     5        IS_IDENTICAL                                     ~4      !0, !1
          6        ADD_ARRAY_ELEMENT                                ~3      ~4
   18     7        GET_CLASS                                        ~5      !0
          8        GET_CLASS                                        ~6      !1
          9        IS_EQUAL                                         ~7      ~5, ~6
         10        ADD_ARRAY_ELEMENT                                ~3      ~7
         11        SEND_VAL                                                 ~3
   15    12        DO_ICALL                                                 
   20    13      > RETURN                                                   null

End of function compare

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

End of function __construct

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.1 ms | 1005 KiB | 20 Q