3v4l.org

run code in 500+ PHP versions simultaneously
<?php $input = '1990-09-15'; // $input = '15-09-1990'; // $input = '1990-49-85'; $a = DateTime::createFromFormat('Y-m-d', $input); if ($a === false) { echo "Invalid format\n"; } $lastError = DateTime::getLastErrors()['warnings'] ?? []; if (reset($lastError) === 'The parsed date was invalid') { echo "Invalid date\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 21
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 9
filename:       /in/PrS63
function name:  (null)
number of ops:  22
compiled vars:  !0 = $input, !1 = $a, !2 = $lastError
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '1990-09-15'
    7     1        INIT_STATIC_METHOD_CALL                                      'DateTime', 'createFromFormat'
          2        SEND_VAL                                                     'Y-m-d'
          3        SEND_VAR                                                     !0
          4        DO_FCALL                                          0  $4      
          5        ASSIGN                                                       !1, $4
    9     6        TYPE_CHECK                                        4          !1
          7      > JMPZ                                                         ~6, ->9
   10     8    >   ECHO                                                         'Invalid+format%0A'
   13     9    >   INIT_STATIC_METHOD_CALL                                      'DateTime', 'getLastErrors'
         10        DO_FCALL                                          0  $7      
         11        FETCH_DIM_IS                                         ~8      $7, 'warnings'
         12        COALESCE                                             ~9      ~8
         13        QM_ASSIGN                                            ~9      <array>
         14        ASSIGN                                                       !2, ~9
   15    15        INIT_FCALL                                                   'reset'
         16        SEND_REF                                                     !2
         17        DO_ICALL                                             $11     
         18        IS_IDENTICAL                                                 $11, 'The+parsed+date+was+invalid'
         19      > JMPZ                                                         ~12, ->21
   17    20    >   ECHO                                                         'Invalid+date%0A'
   18    21    > > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
155.34 ms | 1315 KiB | 14 Q