3v4l.org

run code in 300+ PHP versions simultaneously
<?php $original = new class(12){ public $x; public function __construct($x){ $this->x = $x; } public static function __set_state($state){ return new self($state['x']); } }; $className = get_class($original); $export = var_export($original, true); $export = str_replace($className, "(" . var_export($className, true) . ")", $export); $imported = eval("return {$export};"); echo "// Modified export: \n", $export, "\n\n"; echo "// Original:\n"; var_dump($original); echo "// Imported:\n"; var_dump($imported);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RXBTu
function name:  (null)
number of ops:  41
compiled vars:  !0 = $original, !1 = $className, !2 = $export, !3 = $imported
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_ANON_CLASS                               <true>  
          1        NEW                                              $5      $4
          2        SEND_VAL_EX                                              12
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $5
   13     5        GET_CLASS                                        ~8      !0
          6        ASSIGN                                                   !1, ~8
   15     7        INIT_FCALL                                               'var_export'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 <true>
         10        DO_ICALL                                         $10     
         11        ASSIGN                                                   !2, $10
   16    12        INIT_FCALL                                               'str_replace'
         13        SEND_VAR                                                 !1
         14        INIT_FCALL                                               'var_export'
         15        SEND_VAR                                                 !1
         16        SEND_VAL                                                 <true>
         17        DO_ICALL                                         $12     
         18        CONCAT                                           ~13     '%28', $12
         19        CONCAT                                           ~14     ~13, '%29'
         20        SEND_VAL                                                 ~14
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $15     
         23        ASSIGN                                                   !2, $15
   18    24        ROPE_INIT                                     3  ~18     'return+'
         25        ROPE_ADD                                      1  ~18     ~18, !2
         26        ROPE_END                                      2  ~17     ~18, '%3B'
         27        INCLUDE_OR_EVAL                                  $20     ~17, EVAL
         28        ASSIGN                                                   !3, $20
   20    29        ECHO                                                     '%2F%2F+Modified+export%3A+%0A'
         30        ECHO                                                     !2
         31        ECHO                                                     '%0A%0A'
   21    32        ECHO                                                     '%2F%2F+Original%3A%0A'
   22    33        INIT_FCALL                                               'var_dump'
         34        SEND_VAR                                                 !0
         35        DO_ICALL                                                 
   23    36        ECHO                                                     '%2F%2F+Imported%3A%0A'
   24    37        INIT_FCALL                                               'var_dump'
         38        SEND_VAR                                                 !3
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

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

End of function __construct

Function __set_state:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RXBTu
function name:  __set_state
number of ops:  8
compiled vars:  !0 = $state
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        NEW                          self                $1      
          2        CHECK_FUNC_ARG                                           
          3        FETCH_DIM_FUNC_ARG                               $2      !0, 'x'
          4        SEND_FUNC_ARG                                            $2
          5        DO_FCALL                                      0          
          6      > RETURN                                                   $1
   10     7*     > RETURN                                                   null

End of function __set_state

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.15 ms | 986 KiB | 16 Q