dqpfkzu360216 2016-11-23 10:34
浏览 96

使用static ::关键字的最低PHP版本是多少?

When using something like

class MyClass
{
    public static function myFunction()
    {
        static::myOtherFunction();
    }

    private static function myOtherFunction()
    {
        …
    }
}

the PHP parser will complain

Parse error: syntax error, unexpected T_STATIC in ….php on line …

in older PHP versions. I couldn't find a reference though, what the minimum PHP version would be to use the static keyword like that.

  • 写回答

2条回答 默认 最新

  • douwenan9849 2016-11-23 10:38
    关注

    It's 5.3.0

    As of PHP 5.3.0, it's possible to reference the class using a variable. The variable's value cannot be a keyword (e.g. self, parent and static).

    via http://php.net/manual/en/language.oop5.static.php

    评论

报告相同问题?