3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @param string $date format rrrr-mm-dd * @return mixed - false or date format d.m.rrrr which really exists */ function typicalFormat($date){ /*$date = explode('-', $date); if(count($date) == 3){ $year = $date[0]; $date[1] = preg_replace('~^0~', '', $date[1]); $date[0] = preg_replace('~^0~', '', $date[2]); $date[2] = $year; $date = implode('.', $date);*/ $date = date('j.n.Y', strtotime($date)); if(existsDate($date, false) == 1){ return $date; } return false; } /** * @param string $date format d.m.rrrr * @return bool * @copyright Jakub Vrána, http://php.vrana.cz/ */ function existsDate($date, $millenium = true){ $millenium = ($millenium) ? '4' : '1,'; return preg_match('~^([1-9]|19|[12][0-8]|29(?=\\.([^2]|2\\.(([02468][048]|[13579][26])00|[0-9]{2}(0[48]|[2468][048]|[13579][26]))))|30(?=\\.[^2])|31(?=\\.([13578][02]?\\.)))\\.([1-9]|1[012])\\.[0-9]{'.$millenium.'}$~D', $date); } var_dump(typicalFormat('999-02-05')); die();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/P9Nqq
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'typicalformat'
          2        SEND_VAL                                                 '999-02-05'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > EXIT                                                     
          7*     > RETURN                                                   1

Function typicalformat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P9Nqq
function name:  typicalFormat
number of ops:  18
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   17     1        INIT_FCALL                                               'date'
          2        SEND_VAL                                                 'j.n.Y'
          3        INIT_FCALL                                               'strtotime'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6        SEND_VAR                                                 $1
          7        DO_ICALL                                         $2      
          8        ASSIGN                                                   !0, $2
   18     9        INIT_FCALL_BY_NAME                                       'existsDate'
         10        SEND_VAR_EX                                              !0
         11        SEND_VAL_EX                                              <false>
         12        DO_FCALL                                      0  $4      
         13        IS_EQUAL                                                 $4, 1
         14      > JMPZ                                                     ~5, ->16
   19    15    > > RETURN                                                   !0
   21    16    > > RETURN                                                   <false>
   22    17*     > RETURN                                                   null

End of function typicalformat

Function existsdate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P9Nqq
function name:  existsDate
number of ops:  15
compiled vars:  !0 = $date, !1 = $millenium
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <true>
   30     2      > JMPZ                                                     !1, ->5
          3    >   QM_ASSIGN                                        ~2      '4'
          4      > JMP                                                      ->6
          5    >   QM_ASSIGN                                        ~2      '1%2C'
          6    >   ASSIGN                                                   !1, ~2
   31     7        INIT_FCALL                                               'preg_match'
          8        CONCAT                                           ~4      '%7E%5E%28%5B1-9%5D%7C19%7C%5B12%5D%5B0-8%5D%7C29%28%3F%3D%5C.%28%5B%5E2%5D%7C2%5C.%28%28%5B02468%5D%5B048%5D%7C%5B13579%5D%5B26%5D%2900%7C%5B0-9%5D%7B2%7D%280%5B48%5D%7C%5B2468%5D%5B048%5D%7C%5B13579%5D%5B26%5D%29%29%29%29%7C30%28%3F%3D%5C.%5B%5E2%5D%29%7C31%28%3F%3D%5C.%28%5B13578%5D%5B02%5D%3F%5C.%29%29%29%5C.%28%5B1-9%5D%7C1%5B012%5D%29%5C.%5B0-9%5D%7B', !1
          9        CONCAT                                           ~5      ~4, '%7D%24%7ED'
         10        SEND_VAL                                                 ~5
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $6      
         13      > RETURN                                                   $6
   32    14*     > RETURN                                                   null

End of function existsdate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.72 ms | 1407 KiB | 22 Q