解析错误:语法错误,意外的'const'(T_CONST),Laravel项目中的预期变量(T_VARIABLE) [英] Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in Laravel project
问题描述
在Bluehost cPanel中上传后,我的Laravel项目中出现以下错误。但是在本地服务器中没有错误。
I have got the following error in my Laravel project after uploading in Bluehost cPanel. But in local server there is no error.
解析错误:语法错误,意外的'const'(T_CONST),期望变量(T_VARIABLE)
Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE)
这是代码
<?php
namespace Doctrine\DBAL;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Closure;
use Exception;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Cache\ResultCacheStatement;
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\Cache\ArrayStatement;
use Doctrine\DBAL\Cache\CacheException;
use Doctrine\DBAL\Driver\PingableConnection;
use Throwable;
use function array_key_exists;
use function array_merge;
use function func_get_args;
use function implode;
use function is_int;
use function is_string;
use function key;
class Connection implements DriverConnection
{
public const TRANSACTION_READ_UNCOMMITTED = TransactionIsolationLevel::READ_UNCOMMITTED;
public const TRANSACTION_READ_COMMITTED = TransactionIsolationLevel::READ_COMMITTED;
public const TRANSACTION_REPEATABLE_READ = TransactionIsolationLevel::REPEATABLE_READ;
public const TRANSACTION_SERIALIZABLE = TransactionIsolationLevel::SERIALIZABLE;
public const PARAM_INT_ARRAY = ParameterType::INTEGER + self::ARRAY_PARAM_OFFSET;
public const PARAM_STR_ARRAY = ParameterType::STRING + self::ARRAY_PARAM_OFFSET;
const ARRAY_PARAM_OFFSET = 100;
protected $_conn;
protected $_config;
protected $_eventManager;
protected $_expr;
private $_isConnected = false;
private $autoCommit = true;
private $_transactionNestingLevel = 0;
private $_transactionIsolationLevel;
private $_nestTransactionsWithSavepoints = false;
private $_params = [];
private $platform;
protected $_schemaManager;
protected $_driver;
private $_isRollbackOnly = false;
protected $defaultFetchMode = FetchMode::ASSOCIATIVE;
我的本地服务器PHP版本是7.2.0
My local server PHP version is 7.2.0
Bluehost PHP版本是7.0.0
Bluehost PHP version is 7.0.0
这是与PHP版本相关的问题吗?
Is that PHP version related problem?
如何修复
推荐答案
仅在PHP 7.1中,才从手册页
The ability to specify the visibility of class constants was only added in PHP 7.1, from the manual page
注意:
自PHP 7.1.0起,类常量允许使用可见性修饰符。
As of PHP 7.1.0 visibility modifiers are allowed for class constants.
因此在PHP 7.0服务器上,
So on the PHP 7.0 server, the
public const TRANSACTION_READ_UNCOMMITTED ...
行不应具有 public
在他们身上。它还表示
lines should not have the public
on them. It also says that
类常量的默认可见性是public。
The default visibility of class constants is public.
所以反正不需要公开。
这篇关于解析错误:语法错误,意外的'const'(T_CONST),Laravel项目中的预期变量(T_VARIABLE)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!