3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * test that filemtime() returns Unix timestamp (UTC) on current system * * @link */ $nowHour = isset($_SERVER['REQUEST_TIME']) ? $_SERVER['REQUEST_TIME'] : time(); $hostname = php_uname('n'); $formatRfc = 'D, d M Y H:i:s O'; $timestampStartOfUnixEpoch = 0; // start of the Unix epoch. $timestampRequest = 3600 * (int)($nowHour / 3600); $tempDir = function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : '/tmp'; $testFile = sprintf('%s/%s', $tempDir, 'test-filemtime'); if ($hostname !== 'php_shell') { printf("PHP version is %s and OS is %s\n", PHP_VERSION, PHP_OS); } printf("Testfile is '%s'.\n", $testFile); touch($testFile, $timestampStartOfUnixEpoch); php_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($formatRfc, $mtime)); touch($testFile, $timestampRequest); php_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($formatRfc, $mtime)); unlink($testFile); /** * @param $clear_realpath_cache * @param $filename * @link http://php.net/manual/en/function.version-compare.php */ function php_clearstatcache($clear_realpath_cache, $filename) { if (version_compare(PHP_VERSION, '5.3.0') >= 0) { clearstatcache($clear_realpath_cache, $filename); } else { clearstatcache(); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 44
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 44
Branch analysis from position: 39
Branch analysis from position: 44
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
Branch analysis from position: 29
filename:       /in/9uBQg
function name:  (null)
number of ops:  110
compiled vars:  !0 = $nowHour, !1 = $hostname, !2 = $formatRfc, !3 = $timestampStartOfUnixEpoch, !4 = $timestampRequest, !5 = $tempDir, !6 = $testFile, !7 = $mtime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_IS                                         ~8      '_SERVER'
          1        ISSET_ISEMPTY_DIM_OBJ                         0          ~8, 'REQUEST_TIME'
          2      > JMPZ                                                     ~9, ->7
          3    >   FETCH_R                      global              ~10     '_SERVER'
          4        FETCH_DIM_R                                      ~11     ~10, 'REQUEST_TIME'
          5        QM_ASSIGN                                        ~12     ~11
          6      > JMP                                                      ->10
          7    >   INIT_FCALL                                               'time'
          8        DO_ICALL                                         $13     
          9        QM_ASSIGN                                        ~12     $13
         10    >   ASSIGN                                                   !0, ~12
    9    11        INIT_FCALL                                               'php_uname'
         12        SEND_VAL                                                 'n'
         13        DO_ICALL                                         $15     
         14        ASSIGN                                                   !1, $15
   10    15        ASSIGN                                                   !2, 'D%2C+d+M+Y+H%3Ai%3As+O'
   12    16        ASSIGN                                                   !3, 0
   13    17        DIV                                              ~19     !0, 3600
         18        CAST                                          4  ~20     ~19
         19        MUL                                              ~21     ~20, 3600
         20        ASSIGN                                                   !4, ~21
   15    21        INIT_FCALL                                               'function_exists'
         22        SEND_VAL                                                 'sys_get_temp_dir'
         23        DO_ICALL                                         $23     
         24      > JMPZ                                                     $23, ->29
         25    >   INIT_FCALL                                               'sys_get_temp_dir'
         26        DO_ICALL                                         $24     
         27        QM_ASSIGN                                        ~25     $24
         28      > JMP                                                      ->30
         29    >   QM_ASSIGN                                        ~25     '%2Ftmp'
         30    >   ASSIGN                                                   !5, ~25
   16    31        INIT_FCALL                                               'sprintf'
         32        SEND_VAL                                                 '%25s%2F%25s'
         33        SEND_VAR                                                 !5
         34        SEND_VAL                                                 'test-filemtime'
         35        DO_ICALL                                         $27     
         36        ASSIGN                                                   !6, $27
   18    37        IS_NOT_IDENTICAL                                         !1, 'php_shell'
         38      > JMPZ                                                     ~29, ->44
   19    39    >   INIT_FCALL                                               'printf'
         40        SEND_VAL                                                 'PHP+version+is+%25s+and+OS+is+%25s%0A'
         41        SEND_VAL                                                 '8.0.0'
         42        SEND_VAL                                                 'Linux'
         43        DO_ICALL                                                 
   21    44    >   INIT_FCALL                                               'printf'
         45        SEND_VAL                                                 'Testfile+is+%27%25s%27.%0A'
         46        SEND_VAR                                                 !6
         47        DO_ICALL                                                 
   23    48        INIT_FCALL                                               'touch'
         49        SEND_VAR                                                 !6
         50        SEND_VAR                                                 !3
         51        DO_ICALL                                                 
   24    52        INIT_FCALL_BY_NAME                                       'php_clearstatcache'
         53        SEND_VAL_EX                                              <false>
         54        SEND_VAR_EX                                              !6
         55        DO_FCALL                                      0          
   25    56        INIT_FCALL                                               'filemtime'
         57        SEND_VAR                                                 !6
         58        DO_ICALL                                         $34     
         59        ASSIGN                                                   !7, $34
   26    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                                                 !6
         64        DO_ICALL                                         $36     
         65        SEND_VAR                                                 $36
         66        SEND_VAR                                                 !3
         67        SEND_VAR                                                 !7
         68        DO_ICALL                                                 
   27    69        INIT_FCALL                                               'printf'
         70        SEND_VAL                                                 'The+mtime+represents+%25s%0A'
         71        INIT_FCALL                                               'date'
         72        SEND_VAR                                                 !2
         73        SEND_VAR                                                 !7
         74        DO_ICALL                                         $38     
         75        SEND_VAR                                                 $38
         76        DO_ICALL                                                 
   29    77        INIT_FCALL                                               'touch'
         78        SEND_VAR                                                 !6
         79        SEND_VAR                                                 !4
         80        DO_ICALL                                                 
   30    81        INIT_FCALL_BY_NAME                                       'php_clearstatcache'
         82        SEND_VAL_EX                                              <false>
         83        SEND_VAR_EX                                              !6
         84        DO_FCALL                                      0          
   31    85        INIT_FCALL                                               'filemtime'
         86        SEND_VAR                                                 !6
         87        DO_ICALL                                         $42     
         88        ASSIGN                                                   !7, $42
   32    89        INIT_FCALL                                               'printf'
         90        SEND_VAL                                                 'Testfile+%27%25s%27+mtime+should+be+from+touch+%25d%2C+is+%25d.%0A'
         91        INIT_FCALL                                               'basename'
         92        SEND_VAR                                                 !6
         93        DO_ICALL                                         $44     
         94        SEND_VAR                                                 $44
         95        SEND_VAR                                                 !4
         96        SEND_VAR                                                 !7
         97        DO_ICALL                                                 
   33    98        INIT_FCALL                                               'printf'
         99        SEND_VAL                                                 'The+mtime+represents+%25s%0A'
        100        INIT_FCALL                                               'date'
        101        SEND_VAR                                                 !2
        102        SEND_VAR                                                 !7
        103        DO_ICALL                                         $46     
        104        SEND_VAR                                                 $46
        105        DO_ICALL                                                 
   35   106        INIT_FCALL                                               'unlink'
        107        SEND_VAR                                                 !6
        108        DO_ICALL                                                 
   48   109      > RETURN                                                   1

Function php_clearstatcache:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9uBQg
function name:  php_clearstatcache
number of ops:  16
compiled vars:  !0 = $clear_realpath_cache, !1 = $filename
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   43     2        INIT_FCALL                                               'version_compare'
          3        SEND_VAL                                                 '8.0.0'
          4        SEND_VAL                                                 '5.3.0'
          5        DO_ICALL                                         $2      
          6        IS_SMALLER_OR_EQUAL                                      0, $2
          7      > JMPZ                                                     ~3, ->13
   44     8    >   INIT_FCALL                                               'clearstatcache'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
         12      > JMP                                                      ->15
   46    13    >   INIT_FCALL                                               'clearstatcache'
         14        DO_ICALL                                                 
   48    15    > > RETURN                                                   null

End of function php_clearstatcache

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.27 ms | 1408 KiB | 39 Q