3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * test that filemtime() returns Unix timestamp (UTC) on current system */ $timestampStartOfUnixEpoch = 0; // start of the Unix epoch. $timestampRequest = 3600 * (int) ($_SERVER['REQUEST_TIME'] / 3600); $testFile = sprintf('%s/%s', sys_get_temp_dir(), 'test-filemtime'); printf("Testfile is '%s'.\n", $testFile); touch($testFile, $timestampStartOfUnixEpoch); clearstatcache(false, $testFile); $mtime = filemtime($testFile); printf("Testfile '%s' mtime should be from touch %d, is %d.\n", basename($testFile), $timestampStartOfUnixEpoch, $mtime); printf("The mtime represents %s\n", date('r', $mtime)); touch($testFile, $timestampRequest); clearstatcache(false, $testFile); $mtime = filemtime($testFile); printf("Testfile '%s' mtime should be from touch %d, is %d.\n", basename($testFile), $timestampRequest, $mtime); printf("The mtime represents %s\n", date('r', $mtime)); unlink($testFile);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aaVh3
function name:  (null)
number of ops:  81
compiled vars:  !0 = $timestampStartOfUnixEpoch, !1 = $timestampRequest, !2 = $testFile, !3 = $mtime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, 0
    7     1        FETCH_R                      global              ~5      '_SERVER'
          2        FETCH_DIM_R                                      ~6      ~5, 'REQUEST_TIME'
          3        DIV                                              ~7      ~6, 3600
          4        CAST                                          4  ~8      ~7
          5        MUL                                              ~9      ~8, 3600
          6        ASSIGN                                                   !1, ~9
    9     7        INIT_FCALL                                               'sprintf'
          8        SEND_VAL                                                 '%25s%2F%25s'
          9        INIT_FCALL                                               'sys_get_temp_dir'
         10        DO_ICALL                                         $11     
         11        SEND_VAR                                                 $11
         12        SEND_VAL                                                 'test-filemtime'
         13        DO_ICALL                                         $12     
         14        ASSIGN                                                   !2, $12
   11    15        INIT_FCALL                                               'printf'
         16        SEND_VAL                                                 'Testfile+is+%27%25s%27.%0A'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                                 
   13    19        INIT_FCALL                                               'touch'
         20        SEND_VAR                                                 !2
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                                 
   14    23        INIT_FCALL                                               'clearstatcache'
         24        SEND_VAL                                                 <false>
         25        SEND_VAR                                                 !2
         26        DO_ICALL                                                 
   15    27        INIT_FCALL                                               'filemtime'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                         $17     
         30        ASSIGN                                                   !3, $17
   16    31        INIT_FCALL                                               'printf'
         32        SEND_VAL                                                 'Testfile+%27%25s%27+mtime+should+be+from+touch+%25d%2C+is+%25d.%0A'
         33        INIT_FCALL                                               'basename'
         34        SEND_VAR                                                 !2
         35        DO_ICALL                                         $19     
         36        SEND_VAR                                                 $19
         37        SEND_VAR                                                 !0
         38        SEND_VAR                                                 !3
         39        DO_ICALL                                                 
   17    40        INIT_FCALL                                               'printf'
         41        SEND_VAL                                                 'The+mtime+represents+%25s%0A'
         42        INIT_FCALL                                               'date'
         43        SEND_VAL                                                 'r'
         44        SEND_VAR                                                 !3
         45        DO_ICALL                                         $21     
         46        SEND_VAR                                                 $21
         47        DO_ICALL                                                 
   19    48        INIT_FCALL                                               'touch'
         49        SEND_VAR                                                 !2
         50        SEND_VAR                                                 !1
         51        DO_ICALL                                                 
   20    52        INIT_FCALL                                               'clearstatcache'
         53        SEND_VAL                                                 <false>
         54        SEND_VAR                                                 !2
         55        DO_ICALL                                                 
   21    56        INIT_FCALL                                               'filemtime'
         57        SEND_VAR                                                 !2
         58        DO_ICALL                                         $25     
         59        ASSIGN                                                   !3, $25
   22    60        INIT_FCALL                                               'printf'
         61        SEND_VAL                                                 'Testfile+%27%25s%27+mtime+should+be+from+touch+%25d%2C+is+%25d.%0A'
         62        INIT_FCALL                                               'basename'
         63        SEND_VAR                                                 !2
         64        DO_ICALL                                         $27     
         65        SEND_VAR                                                 $27
         66        SEND_VAR                                                 !1
         67        SEND_VAR                                                 !3
         68        DO_ICALL                                                 
   23    69        INIT_FCALL                                               'printf'
         70        SEND_VAL                                                 'The+mtime+represents+%25s%0A'
         71        INIT_FCALL                                               'date'
         72        SEND_VAL                                                 'r'
         73        SEND_VAR                                                 !3
         74        DO_ICALL                                         $29     
         75        SEND_VAR                                                 $29
         76        DO_ICALL                                                 
   25    77        INIT_FCALL                                               'unlink'
         78        SEND_VAR                                                 !2
         79        DO_ICALL                                                 
         80      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.1 ms | 1400 KiB | 31 Q