3v4l.org

run code in 300+ PHP versions simultaneously
<?php //get the last-modified-date of this very file $lastModified=filemtime($_SERVER['SCRIPT_FILENAME']); //get a unique hash of this file (etag) $etagFile = md5_file($_SERVER['SCRIPT_FILENAME']); //get the HTTP_IF_MODIFIED_SINCE header if set $ifModifiedSince=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false); //get the HTTP_IF_NONE_MATCH header if set (etag: unique file hash) $etagHeader=(isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : false); header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastModified)." GMT"); header("Etag: $etagFile"); $ttc=60*60*24*8; header('Cache-Control: private; max-age='.$ttc); header('Expires: '.gmdate("D, d M Y H:i:s", time() + $ttc)); header("Pragma: cache"); //check if page has changed. If not, send 304 and exit if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])==$lastModified || $etagHeader == $etagFile) { header("HTTP/1.1 304 Not Modified"); exit; } //your normal code echo "<!-- This page was last modified: ".date("d.m.Y H:i:s",$lastModified)." -->"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 47) Position 1 = 75, Position 2 = 77
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 78, Position 2 = 82
Branch analysis from position: 78
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 77
Branch analysis from position: 31
2 jumps found. (Code = 47) Position 1 = 75, Position 2 = 77
Branch analysis from position: 75
Branch analysis from position: 77
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
Branch analysis from position: 31
filename:       /in/fGY9e
function name:  (null)
number of ops:  90
compiled vars:  !0 = $lastModified, !1 = $etagFile, !2 = $ifModifiedSince, !3 = $etagHeader, !4 = $ttc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'filemtime'
          1        FETCH_R                      global              ~5      '_SERVER'
          2        FETCH_DIM_R                                      ~6      ~5, 'SCRIPT_FILENAME'
          3        SEND_VAL                                                 ~6
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !0, $7
    5     6        INIT_FCALL                                               'md5_file'
          7        FETCH_R                      global              ~9      '_SERVER'
          8        FETCH_DIM_R                                      ~10     ~9, 'SCRIPT_FILENAME'
          9        SEND_VAL                                                 ~10
         10        DO_ICALL                                         $11     
         11        ASSIGN                                                   !1, $11
    7    12        FETCH_IS                                         ~13     '_SERVER'
         13        ISSET_ISEMPTY_DIM_OBJ                         0          ~13, 'HTTP_IF_MODIFIED_SINCE'
         14      > JMPZ                                                     ~14, ->19
         15    >   FETCH_R                      global              ~15     '_SERVER'
         16        FETCH_DIM_R                                      ~16     ~15, 'HTTP_IF_MODIFIED_SINCE'
         17        QM_ASSIGN                                        ~17     ~16
         18      > JMP                                                      ->20
         19    >   QM_ASSIGN                                        ~17     <false>
         20    >   ASSIGN                                                   !2, ~17
    9    21        FETCH_IS                                         ~19     '_SERVER'
         22        ISSET_ISEMPTY_DIM_OBJ                         0          ~19, 'HTTP_IF_NONE_MATCH'
         23      > JMPZ                                                     ~20, ->31
         24    >   INIT_FCALL                                               'trim'
         25        FETCH_R                      global              ~21     '_SERVER'
         26        FETCH_DIM_R                                      ~22     ~21, 'HTTP_IF_NONE_MATCH'
         27        SEND_VAL                                                 ~22
         28        DO_ICALL                                         $23     
         29        QM_ASSIGN                                        ~24     $23
         30      > JMP                                                      ->32
         31    >   QM_ASSIGN                                        ~24     <false>
         32    >   ASSIGN                                                   !3, ~24
   11    33        INIT_FCALL                                               'header'
         34        INIT_FCALL                                               'gmdate'
         35        SEND_VAL                                                 'D%2C+d+M+Y+H%3Ai%3As'
         36        SEND_VAR                                                 !0
         37        DO_ICALL                                         $26     
         38        CONCAT                                           ~27     'Last-Modified%3A+', $26
         39        CONCAT                                           ~28     ~27, '+GMT'
         40        SEND_VAL                                                 ~28
         41        DO_ICALL                                                 
   13    42        INIT_FCALL                                               'header'
         43        NOP                                                      
         44        FAST_CONCAT                                      ~30     'Etag%3A+', !1
         45        SEND_VAL                                                 ~30
         46        DO_ICALL                                                 
   15    47        ASSIGN                                                   !4, 691200
   17    48        INIT_FCALL                                               'header'
         49        CONCAT                                           ~33     'Cache-Control%3A+private%3B+max-age%3D', !4
         50        SEND_VAL                                                 ~33
         51        DO_ICALL                                                 
   19    52        INIT_FCALL                                               'header'
         53        INIT_FCALL                                               'gmdate'
         54        SEND_VAL                                                 'D%2C+d+M+Y+H%3Ai%3As'
         55        INIT_FCALL                                               'time'
         56        DO_ICALL                                         $35     
         57        ADD                                              ~36     $35, !4
         58        SEND_VAL                                                 ~36
         59        DO_ICALL                                         $37     
         60        CONCAT                                           ~38     'Expires%3A+', $37
         61        SEND_VAL                                                 ~38
         62        DO_ICALL                                                 
   21    63        INIT_FCALL                                               'header'
         64        SEND_VAL                                                 'Pragma%3A+cache'
         65        DO_ICALL                                                 
   24    66        BEGIN_SILENCE                                    ~41     
         67        INIT_FCALL                                               'strtotime'
         68        FETCH_R                      global              ~42     '_SERVER'
         69        FETCH_DIM_R                                      ~43     ~42, 'HTTP_IF_MODIFIED_SINCE'
         70        SEND_VAL                                                 ~43
         71        DO_ICALL                                         $44     
         72        END_SILENCE                                              ~41
         73        IS_EQUAL                                         ~45     !0, $44
         74      > JMPNZ_EX                                         ~45     ~45, ->77
         75    >   IS_EQUAL                                         ~46     !3, !1
         76        BOOL                                             ~45     ~46
         77    > > JMPZ                                                     ~45, ->82
   26    78    >   INIT_FCALL                                               'header'
         79        SEND_VAL                                                 'HTTP%2F1.1+304+Not+Modified'
         80        DO_ICALL                                                 
   27    81      > EXIT                                                     
   31    82    >   INIT_FCALL                                               'date'
         83        SEND_VAL                                                 'd.m.Y+H%3Ai%3As'
         84        SEND_VAR                                                 !0
         85        DO_ICALL                                         $48     
         86        CONCAT                                           ~49     '%3C%21--+This+page+was+last+modified%3A+', $48
         87        CONCAT                                           ~50     ~49, '+--%3E'
         88        ECHO                                                     ~50
   33    89      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.23 ms | 1404 KiB | 29 Q