Php 分析错误:语法错误,意外';常数';(T_CONST),Laravel项目中的预期变量(T_variable)
在Bluehost cPanel中上传后,我的Laravel项目中出现以下错误。但在本地服务器中没有错误 分析错误:语法错误,意外的'const'(T_const),应为变量(T_variable) 这是密码Php 分析错误:语法错误,意外';常数';(T_CONST),Laravel项目中的预期变量(T_variable),php,laravel,laravel-5,Php,Laravel,Laravel 5,在Bluehost cPanel中上传后,我的Laravel项目中出现以下错误。但在本地服务器中没有错误 分析错误:语法错误,意外的'const'(T_const),应为变量(T_variable) 这是密码 <?php namespace Doctrine\DBAL; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Exception\InvalidArgumentException; use C
<?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;
指定类常量可见性的功能仅在PHP7.1中添加,从
注意:
从PHP7.1.0开始,类常量允许使用可见性修饰符
因此,在PHP7.0服务器上
public const TRANSACTION_READ_UNCOMMITTED ...
行上不应该有public
。它还说
类常量的默认可见性为public
因此,无论如何都不需要public。您似乎想要定义一个常量变量
我的指示是:
const CONSTANT = 'jkl';
我得到的错误是:
syntax error, unexpected 'const' (T_CONST) in ...
我将该指示改为:
define('CONSTANT', 'jkl');
echo CONSTANT;
输出:
jkl
“define”方法的语法:
define('variable_name', 'value_of_the_variable', [case-insensitive_constant_name = true/false]);
例如
define('CONSTANT3', 'ghi', true);
echo CONSTANT3;
define('constant3', 'ghi'); //Defining 'constant3' again will give an error.
但是
始终记住,正则变量应在其名称前使用“$”进行寻址,但常量变量应直接寻址,如我在上面的代码中所示。我投票重新打开此问题,因为所谓的重复问题没有解决此错误消息。简单搜索“T_CONST”就会发现这一点。从安装的composer软件包中获取此错误,我们不想降级,因此升级了php:e.g:,
define('CONSTANT3', 'ghi');
echo CONSTANT3;
define('constant3', 'ghi'); //This won't give an error.
echo constant3;