【问题标题】:syntax error, unexpected T_STATIC语法错误,意外的 T_STATIC
【发布时间】:2011-10-16 09:26:57
【问题描述】:

我在尝试使用后期静态绑定时遇到此错误。我在谷歌上能找到关于这个错误的所有信息是人们没有 PHP5.3,但我有 5.3.6 版本。

有人可以帮帮我吗?

谢谢

class Media
{
    private $nom,
            $ext;

    public function ext_autorisees() { return array(); }

    public function __construct( $fichier, $thumb = false )
    {
        $fichier = explode( ".", $fichier );

        $nom = $fichier[0];
        $ext = $fichier[1];

        if( in_array( strtoupper( $ext ), static::ext_autorisees() ) )
        {
            if( strpos( $nom, "thumb_" ) === 0 && !$thumb )
                throw new Exception("");
        }
        else
            throw new Exception("");

        $this->nom = $nom;
        $this->ext = $ext;
    }

    public function getNom() { return $this->nom; }
    public function getExt() { return $this->ext; }
    public function getPath() { return $this->getNom() . "." . $this->getExt(); }
    public function getThumb() { return "thumb_" . $this->getPath(); }

}

【问题讨论】:

  • 这对我来说运行得很好。错误在哪一行?你怎么知道你运行的是 5.3?
  • 因为是我自己安装的...
  • 好吧,奇怪的是,我的目录名为 PHP5.3.6 ,但是当我调用 phpinfo() 它告诉我 PHP 5.2 ...

标签: php late-static-binding


【解决方案1】:

static::ext_autorisees() 有问题

【讨论】:

  • 你可以使用 self::ext_autorisees()
  • 不,我有其他类扩展了那个类,我希望调用他们的 ext_autorisees(),而不是这个类...
猜你喜欢
  • 2011-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-03
  • 1970-01-01
  • 2011-10-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多