3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input_date = '2015'; $date = \DateTime::createFromFormat('Y-m-d', $input_date); if (empty($date)) { $date = \DateTime::createFromFormat('m/d/Y', $input_date); if (empty($date)) { throw new \Exception("Date field asdf not in the required format (MM/DD/YYYY or YYYY-MM-DD)."); } } var_dump($date);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/irLAm
function name:  (null)
number of ops:  23
compiled vars:  !0 = $input_date, !1 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '2015'
    5     1        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
          2        SEND_VAL                                                 'Y-m-d'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
    6     6        ISSET_ISEMPTY_CV                                         !1
          7      > JMPZ                                                     ~5, ->19
    7     8    >   INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
          9        SEND_VAL                                                 'm%2Fd%2FY'
         10        SEND_VAR                                                 !0
         11        DO_FCALL                                      0  $6      
         12        ASSIGN                                                   !1, $6
    8    13        ISSET_ISEMPTY_CV                                         !1
         14      > JMPZ                                                     ~8, ->19
    9    15    >   NEW                                              $9      'Exception'
         16        SEND_VAL_EX                                              'Date+field+asdf+not+in+the+required+format+%28MM%2FDD%2FYYYY+or+YYYY-MM-DD%29.'
         17        DO_FCALL                                      0          
         18      > THROW                                         0          $9
   13    19    >   INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.89 ms | 1395 KiB | 15 Q