【发布时间】:2015-07-12 12:43:24
【问题描述】:
自从我迁移到 Apache 2 CentOS 后,就出现了这个语法错误。
[Sat May 02 17:34:46 2015] [error] [client *] PHP Parse error: syntax error, unexpected '[' in /var/www/html/index.php on line
源代码可以在下面找到,我已经注释了发生错误的地方:
require('roblox.php');
$config = require('config.php');
/*if (isset($_GET['cookie'])){
echo (new RBXLim)->get_cookie();
return;
}*/
$page = isset($_GET['page']) ? $_GET['page'] : false;
$rbxlim = new RBXLim;
$connection = $rbxlim->get_connection();
var_dump($connection);
session_start();
if (!isset($_SESSION['session'])){
$_SESSION['session'] = md5(microtime().rand());
}
if (isset($_SESSION['logged_in'])){
$_SESSION['premium'] = $connection->query("SELECT premium FROM registered WHERE user_id=" . $_SESSION['user_id'])->fetch_assoc()['premium']; // this is where the error occurs
}
我已经在我的个人机器上运行了 PHP 代码,它运行良好,但是当我在我的 VPS 上运行它时出现错误。
你们中有人遇到过这种情况吗?
【问题讨论】:
-
查看PHP版本
-
您的原始服务器可能是 PHP 5.4+,您的新服务器似乎是 PHP