关于php:解析错误:语法错误,意外’const’(T_CONST),期望变量(T_VARIABLE)在laPavel项目中的cPanel

Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in Laravel project in cPanel

本问题已经有最佳答案,请猛点这里访问。

在BluehostCPanel中上传后,我的Laravel项目中出现了以下错误。但是在本地服务器中没有错误。

Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE)

这是密码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?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
esultCacheStatement;
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

Bluehost PHP版本为7.0.0

这是与PHP版本相关的问题吗?

如何解决这个问题?请帮助…


仅在php 7.1中从手册页面添加了指定类常量可见性的功能。

Note:

As of PHP 7.1.0 visibility modifiers are allowed for class constants.

所以在php 7.0服务器上,

1
public const TRANSACTION_READ_UNCOMMITTED ...

行上不应该有public。它还说

The default visibility of class constants is public.

所以不管怎样,公众是不需要的。