3v4l.org

run code in 300+ PHP versions simultaneously
<?php $classNames = array("StdClass", "ArrayObject", "SplFileObject"); foreach($classNames as $className) { var_dump(instanitateWithoutConstructorThroughUnserialize($className)); var_dump(instanitateWithoutConstructorThroughReflection($className)); } function instanitateWithoutConstructorThroughUnserialize($className) { return unserialize(sprintf('O:%d:"%s":0:{}', strlen($className), $className)); } function instanitateWithoutConstructorThroughReflection($className) { try { $ref = new ReflectionClass($className); return $ref->newInstanceWithoutConstructor(); } catch (ReflectionException $e) { return $e; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 16
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/7DM7S
function name:  (null)
number of ops:  18
compiled vars:  !0 = $classNames, !1 = $className
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1      > FE_RESET_R                                       $3      !0, ->16
          2    > > FE_FETCH_R                                               $3, !1, ->16
    5     3    >   INIT_FCALL                                               'var_dump'
          4        INIT_FCALL_BY_NAME                                       'instanitateWithoutConstructorThroughUnserialize'
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
    6     9        INIT_FCALL                                               'var_dump'
         10        INIT_FCALL_BY_NAME                                       'instanitateWithoutConstructorThroughReflection'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0  $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                                 
    4    15      > JMP                                                      ->2
         16    >   FE_FREE                                                  $3
   20    17      > RETURN                                                   1

Function instanitatewithoutconstructorthroughunserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7DM7S
function name:  instanitateWithoutConstructorThroughUnserialize
number of ops:  12
compiled vars:  !0 = $className
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'unserialize'
          2        INIT_FCALL                                               'sprintf'
          3        SEND_VAL                                                 'O%3A%25d%3A%22%25s%22%3A0%3A%7B%7D'
          4        STRLEN                                           ~1      !0
          5        SEND_VAL                                                 ~1
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                         $3      
         10      > RETURN                                                   $3
   11    11*     > RETURN                                                   null

End of function instanitatewithoutconstructorthroughunserialize

Function instanitatewithoutconstructorthroughreflection:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 9
Branch analysis from position: 9
2 jumps found. (Code = 107) Position 1 = 10, Position 2 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7DM7S
function name:  instanitateWithoutConstructorThroughReflection
number of ops:  12
compiled vars:  !0 = $className, !1 = $ref, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        NEW                                              $3      'ReflectionClass'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $3
   16     5        INIT_METHOD_CALL                                         !1, 'newInstanceWithoutConstructor'
          6        DO_FCALL                                      0  $6      
          7      > RETURN                                                   $6
          8*       JMP                                                      ->11
   17     9  E > > CATCH                                       last         'ReflectionException'
   18    10    > > RETURN                                                   !2
   20    11*     > RETURN                                                   null

End of function instanitatewithoutconstructorthroughreflection

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.23 ms | 1392 KiB | 19 Q