3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * test that filemtime() returns Unix timestamp (UTC) on current system */ $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); $testFile = sprintf('%s/%s', php_sys_get_temp_dir(), '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); /** * NOTE: This function is incomplete, the fallback is to '/tmp' which targets Unix-like. * * @return string */ function php_sys_get_temp_dir() { // (PHP 5 >= 5.2.1) if (function_exists('sys_get_temp_dir')) { return sys_get_temp_dir(); } // (PHP 4 >= 4.3.0, PHP 5) if (function_exists('stream_get_meta_data')) { $handle = tmpfile(); // (PHP 4, PHP 5) $meta = stream_get_meta_data($handle); // (PHP 5 >= 5.1.0) if (isset($meta['uri'])) { return dirname($meta['uri']); } } // emulate PHP 4 <= 4.0.6 tempnam() behavior, fragile foreach(array('TMPDIR', 'TMP') as $key) { if (isset($_ENV[$key])) { return $_ENV[$key]; } } // fallback for Unix-like (php_shell specifically) return '/tmp'; } /** * @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 = 31, Position 2 = 36
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 36
Branch analysis from position: 31
Branch analysis from position: 36
filename:       /in/jGmdV
function name:  (null)
number of ops:  102
compiled vars:  !0 = $nowHour, !1 = $hostname, !2 = $formatRfc, !3 = $timestampStartOfUnixEpoch, !4 = $timestampRequest, !5 = $testFile, !6 = $mtime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   FETCH_IS                                         ~7      '_SERVER'
          1        ISSET_ISEMPTY_DIM_OBJ                         0          ~7, 'REQUEST_TIME'
          2      > JMPZ                                                     ~8, ->7
          3    >   FETCH_R                      global              ~9      '_SERVER'
          4        FETCH_DIM_R                                      ~10     ~9, 'REQUEST_TIME'
          5        QM_ASSIGN                                        ~11     ~10
          6      > JMP                                                      ->10
          7    >   INIT_FCALL                                               'time'
          8        DO_ICALL                                         $12     
          9        QM_ASSIGN                                        ~11     $12
         10    >   ASSIGN                                                   !0, ~11
    7    11        INIT_FCALL                                               'php_uname'
         12        SEND_VAL                                                 'n'
         13        DO_ICALL                                         $14     
         14        ASSIGN                                                   !1, $14
    8    15        ASSIGN                                                   !2, 'D%2C+d+M+Y+H%3Ai%3As+O'
   10    16        ASSIGN                                                   !3, 0
   11    17        DIV                                              ~18     !0, 3600
         18        CAST                                          4  ~19     ~18
         19        MUL                                              ~20     ~19, 3600
         20        ASSIGN                                                   !4, ~20
   13    21        INIT_FCALL                                               'sprintf'
         22        SEND_VAL                                                 '%25s%2F%25s'
         23        INIT_FCALL_BY_NAME                                       'php_sys_get_temp_dir'
         24        DO_FCALL                                      0  $22     
         25        SEND_VAR                                                 $22
         26        SEND_VAL                                                 'test-filemtime'
         27        DO_ICALL                                         $23     
         28        ASSIGN                                                   !5, $23
   15    29        IS_NOT_IDENTICAL                                         !1, 'php_shell'
         30      > JMPZ                                                     ~25, ->36
   16    31    >   INIT_FCALL                                               'printf'
         32        SEND_VAL                                                 'PHP+version+is+%25s+and+OS+is+%25s%0A'
         33        SEND_VAL                                                 '8.0.0'
         34        SEND_VAL                                                 'Linux'
         35        DO_ICALL                                                 
   18    36    >   INIT_FCALL                                               'printf'
         37        SEND_VAL                                                 'Testfile+is+%27%25s%27.%0A'
         38        SEND_VAR                                                 !5
         39        DO_ICALL                                                 
   20    40        INIT_FCALL                                               'touch'
         41        SEND_VAR                                                 !5
         42        SEND_VAR                                                 !3
         43        DO_ICALL                                                 
   21    44        INIT_FCALL_BY_NAME                                       'php_clearstatcache'
         45        SEND_VAL_EX                                              <false>
         46        SEND_VAR_EX                                              !5
         47        DO_FCALL                                      0          
   22    48        INIT_FCALL                                               'filemtime'
         49        SEND_VAR                                                 !5
         50        DO_ICALL                                         $30     
         51        ASSIGN                                                   !6, $30
   23    52        INIT_FCALL                                               'printf'
         53        SEND_VAL                                                 'Testfile+%27%25s%27+mtime+should+be+from+touch+%25d%2C+is+%25d.%0A'
         54        INIT_FCALL                                               'basename'
         55        SEND_VAR                                                 !5
         56        DO_ICALL                                         $32     
         57        SEND_VAR                                                 $32
         58        SEND_VAR                                                 !3
         59        SEND_VAR                                                 !6
         60        DO_ICALL                                                 
   24    61        INIT_FCALL                                               'printf'
         62        SEND_VAL                                                 'The+mtime+represents+%25s%0A'
         63        INIT_FCALL                                               'date'
         64        SEND_VAR                                                 !2
         65        SEND_VAR                                                 !6
         66        DO_ICALL                                         $34     
         67        SEND_VAR                                                 $34
         68        DO_ICALL                                                 
   26    69        INIT_FCALL                                               'touch'
         70        SEND_VAR                                                 !5
         71        SEND_VAR                                                 !4
         72        DO_ICALL                                                 
   27    73        INIT_FCALL_BY_NAME                                       'php_clearstatcache'
         74        SEND_VAL_EX                                              <false>
         75        SEND_VAR_EX                                              !5
         76        DO_FCALL                                      0          
   28    77        INIT_FCALL                                               'filemtime'
         78        SEND_VAR                                                 !5
         79        DO_ICALL                                         $38     
         80        ASSIGN                                                   !6, $38
   29    81        INIT_FCALL                                               'printf'
         82        SEND_VAL                                                 'Testfile+%27%25s%27+mtime+should+be+from+touch+%25d%2C+is+%25d.%0A'
         83        INIT_FCALL                                               'basename'
         84        SEND_VAR                                                 !5
         85        DO_ICALL                                         $40     
         86        SEND_VAR                                                 $40
         87        SEND_VAR                                                 !4
         88        SEND_VAR                                                 !6
         89        DO_ICALL                                                 
   30    90        INIT_FCALL                                               'printf'
         91        SEND_VAL                                                 'The+mtime+represents+%25s%0A'
         92        INIT_FCALL                                               'date'
         93        SEND_VAR                                                 !2
         94        SEND_VAR                                                 !6
         95        DO_ICALL                                         $42     
         96        SEND_VAR                                                 $42
         97        DO_ICALL                                                 
   32    98        INIT_FCALL                                               'unlink'
         99        SEND_VAR                                                 !5
        100        DO_ICALL                                                 
   77   101      > RETURN                                                   1

Function php_sys_get_temp_dir:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 35
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 35
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 34
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
Branch analysis from position: 25
filename:       /in/jGmdV
function name:  php_sys_get_temp_dir
number of ops:  38
compiled vars:  !0 = $handle, !1 = $meta, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   INIT_FCALL                                               'function_exists'
          1        SEND_VAL                                                 'sys_get_temp_dir'
          2        DO_ICALL                                         $3      
          3      > JMPZ                                                     $3, ->7
   42     4    >   INIT_FCALL                                               'sys_get_temp_dir'
          5        DO_ICALL                                         $4      
          6      > RETURN                                                   $4
   46     7    >   INIT_FCALL                                               'function_exists'
          8        SEND_VAL                                                 'stream_get_meta_data'
          9        DO_ICALL                                         $5      
         10      > JMPZ                                                     $5, ->25
   47    11    >   INIT_FCALL                                               'tmpfile'
         12        DO_ICALL                                         $6      
         13        ASSIGN                                                   !0, $6
   48    14        INIT_FCALL                                               'stream_get_meta_data'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $8      
         17        ASSIGN                                                   !1, $8
   50    18        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'uri'
         19      > JMPZ                                                     ~10, ->25
   51    20    >   INIT_FCALL                                               'dirname'
         21        FETCH_DIM_R                                      ~11     !1, 'uri'
         22        SEND_VAL                                                 ~11
         23        DO_ICALL                                         $12     
         24      > RETURN                                                   $12
   56    25    > > FE_RESET_R                                       $13     <array>, ->35
         26    > > FE_FETCH_R                                               $13, !2, ->35
   57    27    >   FETCH_IS                                         ~14     '_ENV'
         28        ISSET_ISEMPTY_DIM_OBJ                         0          ~14, !2
         29      > JMPZ                                                     ~15, ->34
   58    30    >   FETCH_R                      global              ~16     '_ENV'
         31        FETCH_DIM_R                                      ~17     ~16, !2
         32        FE_FREE                                                  $13
         33      > RETURN                                                   ~17
   56    34    > > JMP                                                      ->26
         35    >   FE_FREE                                                  $13
   63    36      > RETURN                                                   '%2Ftmp'
   64    37*     > RETURN                                                   null

End of function php_sys_get_temp_dir

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/jGmdV
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
-------------------------------------------------------------------------------------
   71     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   72     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
   73     8    >   INIT_FCALL                                               'clearstatcache'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
         12      > JMP                                                      ->15
   75    13    >   INIT_FCALL                                               'clearstatcache'
         14        DO_ICALL                                                 
   77    15    > > RETURN                                                   null

End of function php_clearstatcache

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.12 ms | 1408 KiB | 45 Q