PHP 移动服务器后出现语法错误
PHP Syntax Error Appearing after moving Servers
自从我转移到 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 支持 return 值的数组取消引用,如 of PHP 5.4 only:
As of PHP 5.4 it is possible to array dereference the result of a function or method call directly. Before it was only possible using a temporary variable.
您的 VPS 可能运行 PHP 5.3 或更低。你应该升级它,因为 PHP 5.3 is EOL.
自从我转移到 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 支持 return 值的数组取消引用,如 of PHP 5.4 only:
As of PHP 5.4 it is possible to array dereference the result of a function or method call directly. Before it was only possible using a temporary variable.
您的 VPS 可能运行 PHP 5.3 或更低。你应该升级它,因为 PHP 5.3 is EOL.