I’m testing some caching code in php:
if (is_readable($cachefile) && (time() - $cachetime
< filemtime($cachefile)))
{
include($cachefile);
[…]
What it should do:
Run include only if $cachefile already exists. If not it’s supposed to proceed without trying to include $cachefile.
What it does:
It tries to load $cachefile every time therefore creating a php warning when it does not exist.
I have no idea how to fix it since I tried just about everything that would normally prevent include from being excecuted. Can someone help?
Thanks!
Try like this
you can use
issetorfile_existsfunctions, here is documentations =>http://php.net/manual/en/function.file-exists.php
http://php.net/manual/en/function.isset.php
Note:
Wrap time() - $cachetimein () , also make sure$cachefile‘s url is right