【发布时间】:2020-10-29 22:11:50
【问题描述】:
我有一个 php 页面,它检查文件是否在服务器上,如果找到该文件,则使其在线回显,但它会永远执行此操作,我只希望它执行一次。
<h3 class="monospace sec2">Server status: </h3>
<?php
ob_start();
while(true){
$filename = '/var/www/html/.online';
if (file_exists($filename)) {
echo '<span style="color:#00FF00;text-align:center;">Online</span>';
ob_end_clean();
} else {
echo '<span style="color:#ff0000;text-align:center;">Offline</span>';
ob_end_clean();
}
}
?>
</div>
它一直在网上回响并继续使页面变长我只想打印一次。你能帮帮我吗?
【问题讨论】:
-
去掉while循环