[英]PHP Read file and check if a certain string exists
So far this is what I have, but it doesn't seem to be working... 到目前为止,这就是我所拥有的,但它似乎并没有起作用......
<?
$file = fopen('wiu.dat','r')
while (wui = fgets($file)){
if ($wui = 'True') {
header("Location: index.html");
die()
} else {
echo"<h2>Down for maintenance.</h2>"
;}}
fclose($fh);
?>
Any feedback would be greatly appreciated 任何反馈将不胜感激
I fixed the obvious problems. 我解决了明显的问题。 I added a semicolon after your first line and after die()
, changed wui
to $wui
in your while
condition, changed $wui = 'True'
to $wui == 'True'
, changed fclose($fh);
我加了一个分号你的第一行后和die()
改wui
到$wui
在while
条件,改变$wui = 'True'
到$wui == 'True'
,改变fclose($fh);
to fclose($file);
fclose($file);
and cleaned up your indentation just so it looks nicer. 并清理你的缩进只是为了让它看起来更好。 From there, I guess the success of the code depends on what you've got inside wiu.dat
. 从那里,我想代码的成功取决于你在wiu.dat
。
<?php
$file = fopen('wiu.dat','r');
while ($wui = fgets($file)) {
if ($wui == 'True') {
header("Location: index.html");
die();
} else {
echo"<h2>Down for maintenance.</h2>";
}
}
fclose($file);
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.