3v4l.org

run code in 300+ PHP versions simultaneously
<?php function time_offset($timezone = null) { if ($timezone <> null) { $offset = false; try { $time = @new DateTime(); @$time->setTimezone(new DateTimeZone($timezone)); $offset = @$time->getOffset(); } catch (Exception $e) { } $output = is_numeric($offset) ? $offset : false; } else { $output = strtotime(date("Y-m-d H:i:s")) - strtotime(gmdate("Y-m-d H:i:s")); } return $output; } var_dump(time_offset());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AW7pG
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'time_offset'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
          5      > RETURN                                                   1

Function time_offset:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 33
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 23
Branch analysis from position: 23
2 jumps found. (Code = 107) Position 1 = 24, Position 2 = -2
Branch analysis from position: 24
filename:       /in/AW7pG
function name:  time_offset
number of ops:  49
compiled vars:  !0 = $timezone, !1 = $offset, !2 = $time, !3 = $e, !4 = $output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV_INIT                                        !0      null
    4     1        IS_NOT_EQUAL                                             !0, null
          2      > JMPZ                                                     ~5, ->33
    5     3    >   ASSIGN                                                   !1, <false>
    7     4        BEGIN_SILENCE                                    ~7      
          5        NEW                                              $8      'DateTime'
          6        DO_FCALL                                      0          
          7        END_SILENCE                                              ~7
          8        ASSIGN                                                   !2, $8
    8     9        BEGIN_SILENCE                                    ~11     
         10        INIT_METHOD_CALL                                         !2, 'setTimezone'
         11        NEW                                              $12     'DateTimeZone'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0          
         14        SEND_VAR_NO_REF_EX                                       $12
         15        DO_FCALL                                      0          
         16        END_SILENCE                                              ~11
    9    17        BEGIN_SILENCE                                    ~15     
         18        INIT_METHOD_CALL                                         !2, 'getOffset'
         19        DO_FCALL                                      0  $16     
         20        END_SILENCE                                              ~15
         21        ASSIGN                                                   !1, $16
         22      > JMP                                                      ->24
   10    23  E > > CATCH                                       last         'Exception'
   12    24    >   INIT_FCALL                                               'is_numeric'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $18     
         27      > JMPZ                                                     $18, ->30
         28    >   QM_ASSIGN                                        ~19     !1
         29      > JMP                                                      ->31
         30    >   QM_ASSIGN                                        ~19     <false>
         31    >   ASSIGN                                                   !4, ~19
         32      > JMP                                                      ->47
   14    33    >   INIT_FCALL                                               'strtotime'
         34        INIT_FCALL                                               'date'
         35        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         36        DO_ICALL                                         $21     
         37        SEND_VAR                                                 $21
         38        DO_ICALL                                         $22     
         39        INIT_FCALL                                               'strtotime'
         40        INIT_FCALL                                               'gmdate'
         41        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         42        DO_ICALL                                         $23     
         43        SEND_VAR                                                 $23
         44        DO_ICALL                                         $24     
         45        SUB                                              ~25     $22, $24
         46        ASSIGN                                                   !4, ~25
   16    47    > > RETURN                                                   !4
   17    48*     > RETURN                                                   null

End of function time_offset

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.68 ms | 1394 KiB | 24 Q