3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyDateTime extends DateTime { public static function createFromFormat($format, $time, $timezone = null) { $version = phpversion(); if(!$timezone) $timezone = new DateTimeZone(date_default_timezone_get()); if((float)$version >= 5.2){ return parent::createFromFormat($format, $time, $timezone); } return new DateTime(date($format, strtotime($time)), $timezone); } } $dateTime = MyDateTime::createFromFormat('Y-m-d', '2013-6-13'); var_dump($dateTime);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QsfkM
function name:  (null)
number of ops:  9
compiled vars:  !0 = $dateTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_STATIC_METHOD_CALL                                  'MyDateTime', 'createFromFormat'
          1        SEND_VAL                                                 'Y-m-d'
          2        SEND_VAL                                                 '2013-6-13'
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   16     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Class MyDateTime:
Function createfromformat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/QsfkM
function name:  createFromFormat
number of ops:  36
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                                               'phpversion'
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !3, $4
    7     6        BOOL_NOT                                         ~6      !2
          7      > JMPZ                                                     ~6, ->14
          8    >   NEW                                              $7      'DateTimeZone'
          9        INIT_FCALL                                               'date_default_timezone_get'
         10        DO_ICALL                                         $8      
         11        SEND_VAR_NO_REF_EX                                       $8
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !2, $7
    8    14    >   CAST                                          5  ~11     !3
         15        IS_SMALLER_OR_EQUAL                                      5.2, ~11
         16      > JMPZ                                                     ~12, ->23
    9    17    >   INIT_STATIC_METHOD_CALL                                  'createFromFormat'
         18        SEND_VAR_EX                                              !0
         19        SEND_VAR_EX                                              !1
         20        SEND_VAR_EX                                              !2
         21        DO_FCALL                                      0  $13     
         22      > RETURN                                                   $13
   11    23    >   NEW                                              $14     'DateTime'
         24        INIT_FCALL                                               'date'
         25        SEND_VAR                                                 !0
         26        INIT_FCALL                                               'strtotime'
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                         $15     
         29        SEND_VAR                                                 $15
         30        DO_ICALL                                         $16     
         31        SEND_VAR_NO_REF_EX                                       $16
         32        SEND_VAR_EX                                              !2
         33        DO_FCALL                                      0          
         34      > RETURN                                                   $14
   12    35*     > RETURN                                                   null

End of function createfromformat

End of class MyDateTime.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.02 ms | 1400 KiB | 23 Q