3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); ini_set('display_errors', 1); set_error_handler(function (int $severity, string $message, string $filename, int $line) { echo "throwing\n"; throw new ErrorException($message, 0, $severity, $filename, $line); }); $stdObject = new stdClass(); //Can't be casted to string //array_diff compares array items CASTING them to string //http://php.net/manual/en/function.array-diff.php try { array_diff(["hello"], [$stdObject]); }catch(ErrorException $ee){ echo "Catched exception: " . $ee->getMessage() . "\n"; } echo "\n----------\n"; try { array_diff([$stdObject], ["hello"]); }catch(ErrorException $ee){ echo "Catched exception: " . $ee->getMessage() . "\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 20
Branch analysis from position: 20
2 jumps found. (Code = 107) Position 1 = 21, Position 2 = -2
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Found catch point at position: 33
Branch analysis from position: 33
2 jumps found. (Code = 107) Position 1 = 34, Position 2 = -2
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2ThvO
function name:  (null)
number of ops:  40
compiled vars:  !0 = $stdObject, !1 = $ee
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
    4     3        INIT_FCALL                                               'ini_set'
          4        SEND_VAL                                                 'display_errors'
          5        SEND_VAL                                                 1
          6        DO_ICALL                                                 
    6     7        INIT_FCALL                                               'set_error_handler'
          8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F2ThvO%3A6%240'
    9     9        SEND_VAL                                                 ~4
         10        DO_ICALL                                                 
   11    11        NEW                                              $6      'stdClass'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !0, $6
   17    14        INIT_FCALL                                               'array_diff'
         15        SEND_VAL                                                 <array>
         16        INIT_ARRAY                                       ~9      !0
         17        SEND_VAL                                                 ~9
         18        DO_ICALL                                                 
         19      > JMP                                                      ->26
   18    20  E > > CATCH                                       last         'ErrorException'
   19    21    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         22        DO_FCALL                                      0  $11     
         23        CONCAT                                           ~12     'Catched+exception%3A+', $11
         24        CONCAT                                           ~13     ~12, '%0A'
         25        ECHO                                                     ~13
   22    26    >   ECHO                                                     '%0A----------%0A'
   25    27        INIT_FCALL                                               'array_diff'
         28        INIT_ARRAY                                       ~14     !0
         29        SEND_VAL                                                 ~14
         30        SEND_VAL                                                 <array>
         31        DO_ICALL                                                 
         32      > JMP                                                      ->39
   26    33  E > > CATCH                                       last         'ErrorException'
   27    34    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         35        DO_FCALL                                      0  $16     
         36        CONCAT                                           ~17     'Catched+exception%3A+', $16
         37        CONCAT                                           ~18     ~17, '%0A'
         38        ECHO                                                     ~18
   28    39    > > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F2ThvO%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/2ThvO
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $severity, !1 = $message, !2 = $filename, !3 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    7     4        ECHO                                                     'throwing%0A'
    8     5        NEW                                              $4      'ErrorException'
          6        SEND_VAR_EX                                              !1
          7        SEND_VAL_EX                                              0
          8        SEND_VAR_EX                                              !0
          9        SEND_VAR_EX                                              !2
         10        SEND_VAR_EX                                              !3
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $4
    9    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F2ThvO%3A6%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.64 ms | 1405 KiB | 21 Q