我已经运行Web应用已有一段时间了。该应用程序即使在发生多个PHP错误后仍能正常工作,但每隔几周后错误日志文件会不断占用我1 GB的空间,这迫使我手动删除它们。错误驻留在faucet.php文件中
我对Php并不熟悉,我已经尽力解决了这个错误,甚至检查了类似的问题,但没有一个能解决我的问题。
这些是四个错误消息,并且整天都在重复。
Undefined variable
PHP Notice: Undefined variable: refer_file in /home/countnet/public_html/faucet/network/mine/doge/faucet.php on **line 318**
PHP Notice: Undefined variable: refer_file in /home/countnet/public_html/faucet/network/mine/doge/faucet.php on **line 393**
And Undefined index
PHP Notice: Undefined index: status in /home/countnet/public_html/faucet/network/mine/doge/faucet.php on **line 604**
PHP Notice: Undefined index: status in /home/countnet/public_html/faucet/network/mine/doge/faucet.php on **line 608**
**Line 318** if (!$refer_file) {
**Line 393** if (!$refer_file) { // the user was referred and the referral isn't saved
**Line 604** echo '\'status\': \'' . htmlspecialchars($result['status'], ENT_QUOTES|ENT_SUBSTITUTE|ENT_DISALLOWED|ENT_HTML5) . '\',';
**Line 608**
echo '<dl><dt>Status</dt><dd>' . htmlspecialchars($result['status'], ENT_QUOTES|ENT_SUBSTITUTE|ENT_DISALLOWED|ENT_HTML5) . '</dd><dt>Message</dt><dd>' . htmlspecialchars($result['message'], ENT_QUOTES|ENT_SUBSTITUTE|ENT_DISALLOWED|ENT_HTML5) . '</dd></dl>';
任何帮助将不胜感激,即使出现这些错误,该应用也能正常运行,但随着流量的增长,它们现在已成为噩梦。
答案 0 :(得分:0)
使用isset来检查数组的变量/索引是否存在。
if (isset($refer_file)) {
if (!$refer_file) { // the user was referred and the referral isn't saved
if(isset($result['status']) && isset($result['message'])){
echo '\'status\': \'' . htmlspecialchars($result['status'], ENT_QUOTES|ENT_SUBSTITUTE|ENT_DISALLOWED|ENT_HTML5) . '\',';}
echo '<dl><dt>Status</dt><dd>' . htmlspecialchars($result['status'], ENT_QUOTES|ENT_SUBSTITUTE|ENT_DISALLOWED|ENT_HTML5) . '</dd><dt>Message</dt><dd>' . htmlspecialchars($result['message'], ENT_QUOTES|ENT_SUBSTITUTE|ENT_DISALLOWED|ENT_HTML5) . '</dd></dl>';
}
答案 1 :(得分:0)