3v4l.org

run code in 300+ PHP versions simultaneously
<?php function createDateFromFormat($format, $time) { $result = \DateTimeImmutable::createFromFormat($format, $time); var_dump($result); var_dump(); if (!$result || \DateTimeImmutable::getLastErrors()['warning_count']) { return false; } return $result; } var_dump(createDateFromFormat('Y-m-d', '2005-12-1')); var_dump(createDateFromFormat('Y-m-d', '2005')); var_dump(\DateTimeImmutable::createFromFormat('Y-m-d|', '2000-15-0')); $errors = \DateTime::getLastErrors(); var_dump(\DateTime::getLastErrors()); if (!empty($errors)) { return false; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GA7fA
function name:  (null)
number of ops:  34
compiled vars:  !0 = $errors
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'createdatefromformat'
          2        SEND_VAL                                                 'Y-m-d'
          3        SEND_VAL                                                 '2005-12-1'
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                                 
   20     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'createdatefromformat'
          9        SEND_VAL                                                 'Y-m-d'
         10        SEND_VAL                                                 '2005'
         11        DO_FCALL                                      0  $3      
         12        SEND_VAR                                                 $3
         13        DO_ICALL                                                 
   23    14        INIT_FCALL                                               'var_dump'
         15        INIT_STATIC_METHOD_CALL                                  'DateTimeImmutable', 'createFromFormat'
         16        SEND_VAL                                                 'Y-m-d%7C'
         17        SEND_VAL                                                 '2000-15-0'
         18        DO_FCALL                                      0  $5      
         19        SEND_VAR                                                 $5
         20        DO_ICALL                                                 
   25    21        INIT_STATIC_METHOD_CALL                                  'DateTime', 'getLastErrors'
         22        DO_FCALL                                      0  $7      
         23        ASSIGN                                                   !0, $7
   26    24        INIT_FCALL                                               'var_dump'
         25        INIT_STATIC_METHOD_CALL                                  'DateTime', 'getLastErrors'
         26        DO_FCALL                                      0  $9      
         27        SEND_VAR                                                 $9
         28        DO_ICALL                                                 
   27    29        ISSET_ISEMPTY_CV                                 ~11     !0
         30        BOOL_NOT                                         ~12     ~11
         31      > JMPZ                                                     ~12, ->33
   28    32    > > RETURN                                                   <false>
   29    33    > > RETURN                                                   1

Function createdatefromformat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/GA7fA
function name:  createDateFromFormat
number of ops:  22
compiled vars:  !0 = $format, !1 = $time, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INIT_STATIC_METHOD_CALL                                  'DateTimeImmutable', 'createFromFormat'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !2, $3
    8     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
    9    10        INIT_FCALL                                               'var_dump'
         11        DO_ICALL                                                 
   11    12        BOOL_NOT                                         ~7      !2
         13      > JMPNZ_EX                                         ~7      ~7, ->18
         14    >   INIT_STATIC_METHOD_CALL                                  'DateTimeImmutable', 'getLastErrors'
         15        DO_FCALL                                      0  $8      
         16        FETCH_DIM_R                                      ~9      $8, 'warning_count'
         17        BOOL                                             ~7      ~9
         18    > > JMPZ                                                     ~7, ->20
   12    19    > > RETURN                                                   <false>
   15    20    > > RETURN                                                   !2
   16    21*     > RETURN                                                   null

End of function createdatefromformat

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
272.63 ms | 1403 KiB | 18 Q