3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyDateTime extends DateTime { public static function createFromFormat($format, $time, $timezone = null) { $version = explode('.', phpversion()); if(!$timezone) $timezone = new DateTimeZone(date_default_timezone_get()); 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 = MyDateTime::createFromFormat('d m, Y', '04 25, 2014'); var_dump($dateTime); var_dump($dateTime->format('Y-m-d'));
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/DdnDP
function name:  (null)
number of ops:  17
compiled vars:  !0 = $dateTime
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   NOP                                                      
         1        NOP                                                      
  15     2        INIT_STATIC_METHOD_CALL                                  'MyDateTime', 'createFromFormat'
         3        SEND_VAL_EX                                              'd+m%2C+Y'
         4        SEND_VAL_EX                                              '04+25%2C+2014'
         5        DO_FCALL                                      0  $3      
         6        ASSIGN                                                   !0, $3
  16     7        INIT_FCALL                                               'var_dump'
         8        SEND_VAR                                                 !0
         9        DO_ICALL                                                 
  17    10        INIT_FCALL                                               'var_dump'
        11        INIT_METHOD_CALL                                         !0, 'format'
        12        SEND_VAL_EX                                              'Y-m-d'
        13        DO_FCALL                                      0  $6      
        14        SEND_VAR                                                 $6
        15        DO_ICALL                                                 
        16      > RETURN                                                   1

Class MyDateTime:
Function createfromformat:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
Jump found. Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
Jump found. Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
Jump found. Position 1 = 32, Position 2 = 39
Branch analysis from position: 32
Jump found. Position 1 = -2
Branch analysis from position: 39
Jump found. Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 26
Branch analysis from position: 18
filename:       /in/DdnDP
function name:  createFromFormat
number of ops:  52
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
   6     3        INIT_FCALL                                               'explode'
         4        SEND_VAL                                                 '.'
         5        INIT_FCALL                                               'phpversion'
         6        DO_ICALL                                         $4      
         7        SEND_VAR                                                 $4
         8        DO_ICALL                                         $5      
         9        ASSIGN                                                   !3, $5
   7    10        BOOL_NOT                                         ~7      !2
        11      > JMPZ                                                     ~7, ->18
        12    >   NEW                                              $8      :-2
        13        INIT_FCALL                                               'date_default_timezone_get'
        14        DO_ICALL                                         $9      
        15        SEND_VAR_NO_REF                               4          $9
        16        DO_FCALL                                      0          
        17        ASSIGN                                                   !2, $8
   8    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, ->39
   9    32    >   FETCH_CLASS                                 514  :21     
        33        INIT_STATIC_METHOD_CALL                                  $21, 'createFromFormat'
        34        SEND_VAR_EX                                              !0
        35        SEND_VAR_EX                                              !1
        36        SEND_VAR_EX                                              !2
        37        DO_FCALL                                      0  $22     
        38      > RETURN                                                   $22
  11    39    >   NEW                                              $23     :9
        40        INIT_FCALL                                               'date'
        41        SEND_VAR                                                 !0
        42        INIT_FCALL                                               'strtotime'
        43        SEND_VAR                                                 !1
        44        DO_ICALL                                         $24     
        45        SEND_VAR                                                 $24
        46        DO_ICALL                                         $25     
        47        SEND_VAR_NO_REF                               4          $25
        48        SEND_VAR_EX                                              !2
        49        DO_FCALL                                      0          
        50      > RETURN                                                   $23
  12    51*     > RETURN                                                   null

End of function createfromformat

End of class MyDateTime.

Generated using Vulcan Logic Dumper, using php 7.2.0