3v4l.org

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

End of function php_clearstatcache

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.66 ms | 1396 KiB | 37 Q