【发布时间】:2015-05-26 08:08:22
【问题描述】:
我一切都正确,我已经关闭了?> php 标签,它仍然显示错误:
解析错误:语法错误,意外\'?>\',期待函数(T_FUNCTION)
这是我的代码:
<?php
class IWP_MMB_ErrorLog extends IWP_MMB_Core {
function __construct() {
parent::__construct();
}
function get_errorLog($args) {
$myfile = fopen(ini_get('error_log'), "r") or die("Unable to open file!");
// Output one line until end-of-file
while (!feof($myfile)) {
$string = fgets($myfile);
$ar = explode("]", $string);
if (!empty($ar[0])) {
$remove = trim($ar[0], "[");
$remove1 = trim($remove, "UTC");
}
if (!empty($ar[1]) && !empty($ar[0])) {
$error_data[] = array(
'date' => $remove1,
'content' => $ar[1],
);
}
}
fclose($myfile);
return $error_data;
}
}
?>
【问题讨论】:
-
请发布您收到的确切错误消息!
-
实际上关闭
?>是多余的,可能会导致任何类型的标头指令出现问题... -
结束 PHP 标记 (
?>) 确实是不需要的,如果它后面没有其他东西的话。它本身不会引起任何问题;之后出现空白字符(空格、换行符)会导致标题问题。最好不要将HTML和PHP混合在同一个文件中,如果您遵循它,那么下一步就是去掉 PHP 文件中的结束 PHP 标记。 -
该错误表明您尚未在某处关闭
}。我看不到您发布的内容的位置,请三重检查您自己的本地代码。