3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getthistime($type, $modify = null){ $now = new DateTime(null, new DateTimeZone('Asia/Baghdad')); if($modify){ $now->modify($modify); } if(!isset($type) || $type == 'datetime'){ return $now->format('Y-m-d H:i:s'); } if($type == 'time'){ return $now->format('H:i:s'); } if($type == 'timestamp'){ return $now->getTimestamp(); } } function timestampfromdate($date){ return DateTime::createFromFormat('Y-m-d H:i:s', $date, new DateTimeZone('Asia/Baghdad'))->getTimestamp(); } echo getthistime('timestamp')."--".timestampfromdate(getthistime('datetime'))."--".strtotime(getthistime('datetime'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BRlmV
function name:  (null)
number of ops:  21
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'getthistime'
          1        SEND_VAL                                                 'timestamp'
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      $0, '--'
          4        INIT_FCALL                                               'timestampfromdate'
          5        INIT_FCALL                                               'getthistime'
          6        SEND_VAL                                                 'datetime'
          7        DO_FCALL                                      0  $2      
          8        SEND_VAR                                                 $2
          9        DO_FCALL                                      0  $3      
         10        CONCAT                                           ~4      ~1, $3
         11        CONCAT                                           ~5      ~4, '--'
         12        INIT_FCALL                                               'strtotime'
         13        INIT_FCALL                                               'getthistime'
         14        SEND_VAL                                                 'datetime'
         15        DO_FCALL                                      0  $6      
         16        SEND_VAR                                                 $6
         17        DO_ICALL                                         $7      
         18        CONCAT                                           ~8      ~5, $7
         19        ECHO                                                     ~8
         20      > RETURN                                                   1

Function getthistime:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 47) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 30
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 35
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
Branch analysis from position: 14
filename:       /in/BRlmV
function name:  getthistime
number of ops:  36
compiled vars:  !0 = $type, !1 = $modify, !2 = $now
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
    3     2        NEW                                              $3      'DateTime'
          3        SEND_VAL_EX                                              null
          4        NEW                                              $4      'DateTimeZone'
          5        SEND_VAL_EX                                              'Asia%2FBaghdad'
          6        DO_FCALL                                      0          
          7        SEND_VAR_NO_REF_EX                                       $4
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !2, $3
    4    10      > JMPZ                                                     !1, ->14
    5    11    >   INIT_METHOD_CALL                                         !2, 'modify'
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0          
    7    14    >   ISSET_ISEMPTY_CV                                 ~9      !0
         15        BOOL_NOT                                         ~10     ~9
         16      > JMPNZ_EX                                         ~10     ~10, ->19
         17    >   IS_EQUAL                                         ~11     !0, 'datetime'
         18        BOOL                                             ~10     ~11
         19    > > JMPZ                                                     ~10, ->24
    8    20    >   INIT_METHOD_CALL                                         !2, 'format'
         21        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As'
         22        DO_FCALL                                      0  $12     
         23      > RETURN                                                   $12
   10    24    >   IS_EQUAL                                                 !0, 'time'
         25      > JMPZ                                                     ~13, ->30
   11    26    >   INIT_METHOD_CALL                                         !2, 'format'
         27        SEND_VAL_EX                                              'H%3Ai%3As'
         28        DO_FCALL                                      0  $14     
         29      > RETURN                                                   $14
   13    30    >   IS_EQUAL                                                 !0, 'timestamp'
         31      > JMPZ                                                     ~15, ->35
   14    32    >   INIT_METHOD_CALL                                         !2, 'getTimestamp'
         33        DO_FCALL                                      0  $16     
         34      > RETURN                                                   $16
   16    35    > > RETURN                                                   null

End of function getthistime

Function timestampfromdate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BRlmV
function name:  timestampfromdate
number of ops:  13
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
          2        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
          3        SEND_VAR                                                 !0
          4        NEW                                              $1      'DateTimeZone'
          5        SEND_VAL_EX                                              'Asia%2FBaghdad'
          6        DO_FCALL                                      0          
          7        SEND_VAR                                                 $1
          8        DO_FCALL                                      0  $3      
          9        INIT_METHOD_CALL                                         $3, 'getTimestamp'
         10        DO_FCALL                                      0  $4      
         11      > RETURN                                                   $4
   19    12*     > RETURN                                                   null

End of function timestampfromdate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.3 ms | 1452 KiB | 18 Q