3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum SomeEnum: int { case A = 1; case B = 2; } class ClassWithToString { public function __toString(): string { return 'foo'; } } echo "--------Wrong:--------\n"; //$curlHandle = curl_init(); //assert($curlHandle !== false); var_dump(array_sum([SomeEnum::A])); var_dump(array_sum([[0]])); var_dump(array_sum([new \stdClass()])); var_dump(array_sum(['ttt'])); var_dump(array_sum([fopen('php://input', 'r')])); //var_dump(array_sum([$curlHandle])); var_dump(array_sum([new ClassWithToString()])); var_dump(array_product([SomeEnum::A])); var_dump(array_product([[0]])); var_dump(array_product([new \stdClass()])); var_dump(array_product(['ttt'])); var_dump(array_product([fopen('php://input', 'r')])); //var_dump(array_product([$curlHandle])); var_dump(array_product([new ClassWithToString()])); echo "--------Correct:--------\n"; var_dump(array_sum(['5.5', false, true, new \SimpleXMLElement('<a>7.7</a>'), 5, 5.5, null])); var_dump(array_product(['5.5', false, true, new \SimpleXMLElement('<a>7.7</a>'), 5, 5.5, null]));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lF7SE
function name:  (null)
number of ops:  135
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'someenum'
    8     1        DECLARE_CLASS                                            'classwithtostring'
   16     2        ECHO                                                     '--------Wrong%3A--------%0A'
   19     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'array_sum'
          5        FETCH_CLASS_CONSTANT                             ~0      'SomeEnum', 'A'
          6        INIT_ARRAY                                       ~1      ~0
          7        SEND_VAL                                                 ~1
          8        DO_ICALL                                         $2      
          9        SEND_VAR                                                 $2
         10        DO_ICALL                                                 
   20    11        INIT_FCALL                                               'var_dump'
         12        INIT_FCALL                                               'array_sum'
         13        SEND_VAL                                                 <array>
         14        DO_ICALL                                         $4      
         15        SEND_VAR                                                 $4
         16        DO_ICALL                                                 
   21    17        INIT_FCALL                                               'var_dump'
         18        INIT_FCALL                                               'array_sum'
         19        NEW                                              $6      'stdClass'
         20        DO_FCALL                                      0          
         21        INIT_ARRAY                                       ~8      $6
         22        SEND_VAL                                                 ~8
         23        DO_ICALL                                         $9      
         24        SEND_VAR                                                 $9
         25        DO_ICALL                                                 
   22    26        INIT_FCALL                                               'var_dump'
         27        INIT_FCALL                                               'array_sum'
         28        SEND_VAL                                                 <array>
         29        DO_ICALL                                         $11     
         30        SEND_VAR                                                 $11
         31        DO_ICALL                                                 
   23    32        INIT_FCALL                                               'var_dump'
         33        INIT_FCALL                                               'array_sum'
         34        INIT_FCALL                                               'fopen'
         35        SEND_VAL                                                 'php%3A%2F%2Finput'
         36        SEND_VAL                                                 'r'
         37        DO_ICALL                                         $13     
         38        INIT_ARRAY                                       ~14     $13
         39        SEND_VAL                                                 ~14
         40        DO_ICALL                                         $15     
         41        SEND_VAR                                                 $15
         42        DO_ICALL                                                 
   25    43        INIT_FCALL                                               'var_dump'
         44        INIT_FCALL                                               'array_sum'
         45        NEW                                              $17     'ClassWithToString'
         46        DO_FCALL                                      0          
         47        INIT_ARRAY                                       ~19     $17
         48        SEND_VAL                                                 ~19
         49        DO_ICALL                                         $20     
         50        SEND_VAR                                                 $20
         51        DO_ICALL                                                 
   27    52        INIT_FCALL                                               'var_dump'
         53        INIT_FCALL                                               'array_product'
         54        FETCH_CLASS_CONSTANT                             ~22     'SomeEnum', 'A'
         55        INIT_ARRAY                                       ~23     ~22
         56        SEND_VAL                                                 ~23
         57        DO_ICALL                                         $24     
         58        SEND_VAR                                                 $24
         59        DO_ICALL                                                 
   28    60        INIT_FCALL                                               'var_dump'
         61        INIT_FCALL                                               'array_product'
         62        SEND_VAL                                                 <array>
         63        DO_ICALL                                         $26     
         64        SEND_VAR                                                 $26
         65        DO_ICALL                                                 
   29    66        INIT_FCALL                                               'var_dump'
         67        INIT_FCALL                                               'array_product'
         68        NEW                                              $28     'stdClass'
         69        DO_FCALL                                      0          
         70        INIT_ARRAY                                       ~30     $28
         71        SEND_VAL                                                 ~30
         72        DO_ICALL                                         $31     
         73        SEND_VAR                                                 $31
         74        DO_ICALL                                                 
   30    75        INIT_FCALL                                               'var_dump'
         76        INIT_FCALL                                               'array_product'
         77        SEND_VAL                                                 <array>
         78        DO_ICALL                                         $33     
         79        SEND_VAR                                                 $33
         80        DO_ICALL                                                 
   31    81        INIT_FCALL                                               'var_dump'
         82        INIT_FCALL                                               'array_product'
         83        INIT_FCALL                                               'fopen'
         84        SEND_VAL                                                 'php%3A%2F%2Finput'
         85        SEND_VAL                                                 'r'
         86        DO_ICALL                                         $35     
         87        INIT_ARRAY                                       ~36     $35
         88        SEND_VAL                                                 ~36
         89        DO_ICALL                                         $37     
         90        SEND_VAR                                                 $37
         91        DO_ICALL                                                 
   33    92        INIT_FCALL                                               'var_dump'
         93        INIT_FCALL                                               'array_product'
         94        NEW                                              $39     'ClassWithToString'
         95        DO_FCALL                                      0          
         96        INIT_ARRAY                                       ~41     $39
         97        SEND_VAL                                                 ~41
         98        DO_ICALL                                         $42     
         99        SEND_VAR                                                 $42
        100        DO_ICALL                                                 
   35   101        ECHO                                                     '--------Correct%3A--------%0A'
   36   102        INIT_FCALL                                               'var_dump'
        103        INIT_FCALL                                               'array_sum'
        104        INIT_ARRAY                                       ~44     '5.5'
        105        ADD_ARRAY_ELEMENT                                ~44     <false>
        106        ADD_ARRAY_ELEMENT                                ~44     <true>
        107        NEW                                              $45     'SimpleXMLElement'
        108        SEND_VAL_EX                                              '%3Ca%3E7.7%3C%2Fa%3E'
        109        DO_FCALL                                      0          
        110        ADD_ARRAY_ELEMENT                                ~44     $45
        111        ADD_ARRAY_ELEMENT                                ~44     5
        112        ADD_ARRAY_ELEMENT                                ~44     5.5
        113        ADD_ARRAY_ELEMENT                                ~44     null
        114        SEND_VAL                                                 ~44
        115        DO_ICALL                                         $47     
        116        SEND_VAR                                                 $47
        117        DO_ICALL                                                 
   37   118        INIT_FCALL                                               'var_dump'
        119        INIT_FCALL                                               'array_product'
        120        INIT_ARRAY                                       ~49     '5.5'
        121        ADD_ARRAY_ELEMENT                                ~49     <false>
        122        ADD_ARRAY_ELEMENT                                ~49     <true>
        123        NEW                                              $50     'SimpleXMLElement'
        124        SEND_VAL_EX                                              '%3Ca%3E7.7%3C%2Fa%3E'
        125        DO_FCALL                                      0          
        126        ADD_ARRAY_ELEMENT                                ~49     $50
        127        ADD_ARRAY_ELEMENT                                ~49     5
        128        ADD_ARRAY_ELEMENT                                ~49     5.5
        129        ADD_ARRAY_ELEMENT                                ~49     null
        130        SEND_VAL                                                 ~49
        131        DO_ICALL                                         $52     
        132        SEND_VAR                                                 $52
        133        DO_ICALL                                                 
        134      > RETURN                                                   1

Class SomeEnum: [no user functions]
Class ClassWithToString:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lF7SE
function name:  __toString
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E > > RETURN                                                   'foo'
   13     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function __tostring

End of class ClassWithToString.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.87 ms | 1014 KiB | 17 Q