3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { } class Bar { } $foo = new Foo(); $foo = change_class($foo, 'Bar'); var_dump($foo); function change_class($object, $new_class) { preg_match('~^O:[0-9]+:"[^"]+":(.+)$~', serialize($object), $matches); return unserialize(sprintf('O:%s:"%s":%s', strlen($new_class), $new_class, $matches[1])); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YDKuU
function name:  (null)
number of ops:  12
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   13     3        INIT_FCALL_BY_NAME                                       'change_class'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAL_EX                                              'Bar'
          6        DO_FCALL                                      0  $4      
          7        ASSIGN                                                   !0, $4
   14     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
   19    11      > RETURN                                                   1

Function change_class:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YDKuU
function name:  change_class
number of ops:  23
compiled vars:  !0 = $object, !1 = $new_class, !2 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAL                                                 '%7E%5EO%3A%5B0-9%5D%2B%3A%22%5B%5E%22%5D%2B%22%3A%28.%2B%29%24%7E'
          4        INIT_FCALL                                               'serialize'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
          8        SEND_REF                                                 !2
          9        DO_ICALL                                                 
   18    10        INIT_FCALL                                               'unserialize'
         11        INIT_FCALL                                               'sprintf'
         12        SEND_VAL                                                 'O%3A%25s%3A%22%25s%22%3A%25s'
         13        STRLEN                                           ~5      !1
         14        SEND_VAL                                                 ~5
         15        SEND_VAR                                                 !1
         16        FETCH_DIM_R                                      ~6      !2, 1
         17        SEND_VAL                                                 ~6
         18        DO_ICALL                                         $7      
         19        SEND_VAR                                                 $7
         20        DO_ICALL                                         $8      
         21      > RETURN                                                   $8
   19    22*     > RETURN                                                   null

End of function change_class

Class Foo: [no user functions]
Class Bar: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.3 ms | 1396 KiB | 23 Q