3v4l.org

run code in 300+ PHP versions simultaneously
<?php if(!class_exists('MyDateTime2')){ class MyDateTime2 extends DateTime { public static function createFromFormat($format, $time, $timezone = null){ if(!$timezone) $timezone = new DateTimeZone(date_default_timezone_get()); $version = explode('.', phpversion()); if(((int)$version[0] >= 5 && (int)$version[1] >= 2 && (int)$version[2] > 17)){ return parent::createFromFormat($format, $time, $timezone); } return new DateTime(date($format, strtotime($time)), $timezone); } } } $dateTime = MyDateTime2::createFromFormat('Y-m-d', '2013-6-13'); var_dump($dateTime); var_dump($dateTime->format('Y-m-d'));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/u65JT
function name:  (null)
number of ops:  21
compiled vars:  !0 = $dateTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'class_exists'
          1        SEND_VAL                                                 'MyDateTime2'
          2        DO_ICALL                                         $1      
          3        BOOL_NOT                                         ~2      $1
          4      > JMPZ                                                     ~2, ->6
    3     5    >   DECLARE_CLASS                                            'mydatetime2', 'datetime'
   15     6    >   INIT_STATIC_METHOD_CALL                                  'MyDateTime2', 'createFromFormat'
          7        SEND_VAL_EX                                              'Y-m-d'
          8        SEND_VAL_EX                                              '2013-6-13'
          9        DO_FCALL                                      0  $3      
         10        ASSIGN                                                   !0, $3
   16    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
   17    14        INIT_FCALL                                               'var_dump'
         15        INIT_METHOD_CALL                                         !0, 'format'
         16        SEND_VAL_EX                                              'Y-m-d'
         17        DO_FCALL                                      0  $6      
         18        SEND_VAR                                                 $6
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Class MyDateTime2:
Function createfromformat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
2 jumps found. (Code = 46) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 38
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 26
Branch analysis from position: 11
filename:       /in/u65JT
function name:  createFromFormat
number of ops:  51
compiled vars:  !0 = $format, !1 = $time, !2 = $timezone, !3 = $version
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
    5     3        BOOL_NOT                                         ~4      !2
          4      > JMPZ                                                     ~4, ->11
          5    >   NEW                                              $5      'DateTimeZone'
          6        INIT_FCALL                                               'date_default_timezone_get'
          7        DO_ICALL                                         $6      
          8        SEND_VAR_NO_REF_EX                                       $6
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $5
    6    11    >   INIT_FCALL                                               'explode'
         12        SEND_VAL                                                 '.'
         13        INIT_FCALL                                               'phpversion'
         14        DO_ICALL                                         $9      
         15        SEND_VAR                                                 $9
         16        DO_ICALL                                         $10     
         17        ASSIGN                                                   !3, $10
    7    18        FETCH_DIM_R                                      ~12     !3, 0
         19        CAST                                          4  ~13     ~12
         20        IS_SMALLER_OR_EQUAL                              ~14     5, ~13
         21      > JMPZ_EX                                          ~14     ~14, ->26
         22    >   FETCH_DIM_R                                      ~15     !3, 1
         23        CAST                                          4  ~16     ~15
         24        IS_SMALLER_OR_EQUAL                              ~17     2, ~16
         25        BOOL                                             ~14     ~17
         26    > > JMPZ_EX                                          ~14     ~14, ->31
         27    >   FETCH_DIM_R                                      ~18     !3, 2
         28        CAST                                          4  ~19     ~18
         29        IS_SMALLER                                       ~20     17, ~19
         30        BOOL                                             ~14     ~20
         31    > > JMPZ                                                     ~14, ->38
    8    32    >   INIT_STATIC_METHOD_CALL                                  'createFromFormat'
         33        SEND_VAR_EX                                              !0
         34        SEND_VAR_EX                                              !1
         35        SEND_VAR_EX                                              !2
         36        DO_FCALL                                      0  $21     
         37      > RETURN                                                   $21
   10    38    >   NEW                                              $22     'DateTime'
         39        INIT_FCALL                                               'date'
         40        SEND_VAR                                                 !0
         41        INIT_FCALL                                               'strtotime'
         42        SEND_VAR                                                 !1
         43        DO_ICALL                                         $23     
         44        SEND_VAR                                                 $23
         45        DO_ICALL                                         $24     
         46        SEND_VAR_NO_REF_EX                                       $24
         47        SEND_VAR_EX                                              !2
         48        DO_FCALL                                      0          
         49      > RETURN                                                   $22
   11    50*     > RETURN                                                   null

End of function createfromformat

End of class MyDateTime2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.87 ms | 1405 KiB | 27 Q