3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input_date = '1/12/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 '$field' 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 = 22
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/PrHid
function name:  (null)
number of ops:  26
compiled vars:  !0 = $input_date, !1 = $date, !2 = $field
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '1%2F12%2F2015'
    5     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
    6     6        ISSET_ISEMPTY_CV                                         !1
          7      > JMPZ                                                     ~6, ->22
    7     8    >   INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
          9        SEND_VAL                                                 'm%2Fd%2FY'
         10        SEND_VAR                                                 !0
         11        DO_FCALL                                      0  $7      
         12        ASSIGN                                                   !1, $7
    8    13        ISSET_ISEMPTY_CV                                         !1
         14      > JMPZ                                                     ~9, ->22
    9    15    >   NEW                                              $10     'Exception'
         16        ROPE_INIT                                     3  ~12     'Date+field+%27'
         17        ROPE_ADD                                      1  ~12     ~12, !2
         18        ROPE_END                                      2  ~11     ~12, '%27+not+in+the+required+format+%28MM%2FDD%2FYYYY+or+YYYY-MM-DD%29.'
         19        SEND_VAL_EX                                              ~11
         20        DO_FCALL                                      0          
         21      > THROW                                         0          $10
   13    22    >   INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.22 ms | 1395 KiB | 15 Q