大家好,我带着一个新问题回来了,我不知道为什么这个不工作…
这是我的IF命令
if(file_exists(__DIR__."/uploads/json_".$hash) &&
filesize(__DIR__."/uploads/json_".$hash) > 100 &&
time()-filemtime(__DIR__."/uploads/json_".$hash) < 168 * 3600 ===FALSE)
我想做的是....A)检查文件是否存在并且超过100字节并且不超过一周…
我真的需要一个内联解决方案,因为我必须在记事本中查找和替换,因为我在脚本中的几个地方都有这个
任何帮助都将是伟大的
好的,这里是完整的代码忽略##url##和##key##与我的最后一组尝试
$hash = hash("sha1","##key##");
if(file_exists(__DIR__."/uploads/json_".$hash) && (filesize(__DIR__."/uploads/json_".$hash) > 100) && (time()-filemtime(__DIR__."/uploads/json_".$hash) < 168 * 3600)){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "###URL###");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
$credits = curl_exec($ch);
curl_close($ch);
$f = fopen(__DIR__."/uploads/json_".$hash,"wb");
fwrite($f,$credits);
fclose($f);
echo "
<script>
alert('"Updated Record'");
</script>";
}else {
$credits = file_get_contents(__DIR__."/uploads/json_".$hash);
}
$creditsun= json_decode($credits, true); // Decode the results into an array
删除末尾=== FALSE ?
if (file_exists(__DIR__."/uploads/json_".$hash) &&
filesize(__DIR__."/uploads/json_".$hash) > 100 &&
time()-filemtime(__DIR__."/uploads/json_".$hash) < 168 * 3600) {
// do stuff here
}
编辑:的否定是通过放置!在整个条件的前面:
if (!(file_exists(__DIR__."/uploads/json_".$hash) &&
filesize(__DIR__."/uploads/json_".$hash) > 100 &&
time()-filemtime(__DIR__."/uploads/json_".$hash) < 168 * 3600)) {
// do stuff here
}
EDIT2:
请看php手册页