[英]Downgrade to PHP 5.3
I've got a line of code that I need to get working in PHP 5.3.3.我有一行代码需要在 PHP 5.3.3 中工作。 I cannot upgrade the PHP version.
我无法升级 PHP 版本。
The error is in the last line below with the::class property错误在下面的最后一行,带有 ::class 属性
(unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$').
(意外的 T_CLASS,需要 T_STRING 或 T_VARIABLE 或 '$')。
The context is:上下文是:
abstract class E
{
public static function validate($value)
{
$reflector = new ReflectionClass(static::class);
Is there any way to get this to work in PHP 5.3.3?有没有办法让它在 PHP 5.3.3 中工作?
::class
constant on classes has been introduced in PHP 5.5. ::class
5.5 中引入了类上的 class 常量。 The equivalent of static::class
in PHP < 5.5 would be get_called_class()
, so the faulty line in your code should look like this: PHP < 5.5 中的
static::class
的等效项是get_called_class()
,因此代码中的错误行应如下所示:
$reflector = new ReflectionClass(get_called_class());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.