3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DateTimeType { private const FORMAT = 'Y-m-d H:i:s'; private const TIMEZONE = 'Europe/Berlin'; public static function isValidDateTimeOld(string $value): bool { $date = DateTime::createFromFormat(self::FORMAT, $value, new DateTimeZone(self::TIMEZONE)); $errors = DateTime::getLastErrors(); return $date && $errors['warning_count'] === 0 && $errors['error_count'] === 0; } public static function isValidDateTimeNew(string $value): bool { $date = DateTime::createFromFormat(self::FORMAT, $value, new DateTimeZone(self::TIMEZONE)); $errors = DateTime::getLastErrors(); return $date && !$errors; } } $dateTimeToCheck = '2022-02-17 13:37:00'; var_dump(DateTimeType::isValidDateTimeOld($dateTimeToCheck)); var_dump(DateTimeType::isValidDateTimeNew($dateTimeToCheck));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hFvIJ
function name:  (null)
number of ops:  14
compiled vars:  !0 = $dateTimeToCheck
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, '2022-02-17+13%3A37%3A00'
   27     1        INIT_FCALL                                               'var_dump'
          2        INIT_STATIC_METHOD_CALL                                  'DateTimeType', 'isValidDateTimeOld'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
   28     7        INIT_FCALL                                               'var_dump'
          8        INIT_STATIC_METHOD_CALL                                  'DateTimeType', 'isValidDateTimeNew'
          9        SEND_VAR                                                 !0
         10        DO_FCALL                                      0  $4      
         11        SEND_VAR                                                 $4
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Class DateTimeType:
Function isvaliddatetimeold:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 17
filename:       /in/hFvIJ
function name:  isValidDateTimeOld
number of ops:  25
compiled vars:  !0 = $value, !1 = $date, !2 = $errors
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
          2        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
          3        SEND_VAR                                                 !0
          4        NEW                                              $3      'DateTimeZone'
          5        SEND_VAL_EX                                              'Europe%2FBerlin'
          6        DO_FCALL                                      0          
          7        SEND_VAR                                                 $3
          8        DO_FCALL                                      0  $5      
          9        ASSIGN                                                   !1, $5
   12    10        INIT_STATIC_METHOD_CALL                                  'DateTime', 'getLastErrors'
         11        DO_FCALL                                      0  $7      
         12        ASSIGN                                                   !2, $7
   14    13      > JMPZ_EX                                          ~9      !1, ->17
         14    >   FETCH_DIM_R                                      ~10     !2, 'warning_count'
         15        IS_IDENTICAL                                     ~11     ~10, 0
         16        BOOL                                             ~9      ~11
         17    > > JMPZ_EX                                          ~9      ~9, ->21
         18    >   FETCH_DIM_R                                      ~12     !2, 'error_count'
         19        IS_IDENTICAL                                     ~13     ~12, 0
         20        BOOL                                             ~9      ~13
         21    >   VERIFY_RETURN_TYPE                                       ~9
         22      > RETURN                                                   ~9
   15    23*       VERIFY_RETURN_TYPE                                       
         24*     > RETURN                                                   null

End of function isvaliddatetimeold

Function isvaliddatetimenew:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/hFvIJ
function name:  isValidDateTimeNew
number of ops:  20
compiled vars:  !0 = $value, !1 = $date, !2 = $errors
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
          2        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
          3        SEND_VAR                                                 !0
          4        NEW                                              $3      'DateTimeZone'
          5        SEND_VAL_EX                                              'Europe%2FBerlin'
          6        DO_FCALL                                      0          
          7        SEND_VAR                                                 $3
          8        DO_FCALL                                      0  $5      
          9        ASSIGN                                                   !1, $5
   20    10        INIT_STATIC_METHOD_CALL                                  'DateTime', 'getLastErrors'
         11        DO_FCALL                                      0  $7      
         12        ASSIGN                                                   !2, $7
   22    13      > JMPZ_EX                                          ~9      !1, ->16
         14    >   BOOL_NOT                                         ~10     !2
         15        BOOL                                             ~9      ~10
         16    >   VERIFY_RETURN_TYPE                                       ~9
         17      > RETURN                                                   ~9
   23    18*       VERIFY_RETURN_TYPE                                       
         19*     > RETURN                                                   null

End of function isvaliddatetimenew

End of class DateTimeType.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.34 ms | 1004 KiB | 14 Q