3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(1 + 1); // int 2 var_dump('1' + '1'); //int 2 class One { public function __toString() { return '1'; } } var_dump(new One + new One); // Object of class One could not be converted to int int 2 var_dump((string)new One + (string)new One); // int 2 var_dump(2 + 2); // int 4 var_dump('2' + '2'); // int 4 class Two { public function __toString() { return '2'; } } var_dump(new Two + new Two); // Notice: Object of class Two could not be converted to int int 2 var_dump((string)new Two + (string)new Two); // int 4
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OHQqq
function name:  (null)
number of ops:  51
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 2
          2        DO_ICALL                                                 
    4     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAL                                                 2
          5        DO_ICALL                                                 
    6     6        DECLARE_CLASS                                            'one'
   12     7        INIT_FCALL                                               'var_dump'
          8        NEW                                              $2      'One'
          9        DO_FCALL                                      0          
         10        NEW                                              $4      'One'
         11        DO_FCALL                                      0          
         12        ADD                                              ~6      $2, $4
         13        SEND_VAL                                                 ~6
         14        DO_ICALL                                                 
   13    15        INIT_FCALL                                               'var_dump'
         16        NEW                                              $8      'One'
         17        DO_FCALL                                      0          
         18        CAST                                          6  ~10     $8
         19        NEW                                              $11     'One'
         20        DO_FCALL                                      0          
         21        CAST                                          6  ~13     $11
         22        ADD                                              ~14     ~10, ~13
         23        SEND_VAL                                                 ~14
         24        DO_ICALL                                                 
   16    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAL                                                 4
         27        DO_ICALL                                                 
   17    28        INIT_FCALL                                               'var_dump'
         29        SEND_VAL                                                 4
         30        DO_ICALL                                                 
   19    31        DECLARE_CLASS                                            'two'
   25    32        INIT_FCALL                                               'var_dump'
         33        NEW                                              $18     'Two'
         34        DO_FCALL                                      0          
         35        NEW                                              $20     'Two'
         36        DO_FCALL                                      0          
         37        ADD                                              ~22     $18, $20
         38        SEND_VAL                                                 ~22
         39        DO_ICALL                                                 
   26    40        INIT_FCALL                                               'var_dump'
         41        NEW                                              $24     'Two'
         42        DO_FCALL                                      0          
         43        CAST                                          6  ~26     $24
         44        NEW                                              $27     'Two'
         45        DO_FCALL                                      0          
         46        CAST                                          6  ~29     $27
         47        ADD                                              ~30     ~26, ~29
         48        SEND_VAL                                                 ~30
         49        DO_ICALL                                                 
         50      > RETURN                                                   1

Class One:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OHQqq
function name:  __toString
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E > > RETURN                                                   '1'
    9     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function __tostring

End of class One.

Class Two:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OHQqq
function name:  __toString
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E > > RETURN                                                   '2'
   22     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function __tostring

End of class Two.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.06 ms | 1392 KiB | 15 Q