Re: Has this always been the case?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yes, this has been always the case. The property initializer in PHP can not
have any expression. It should be constant value.
If you want to use expression here use the constructor.


class MyClass{
  protected $nonStaticField;
  static protected $staticField;
  public function __construct(){
     $this->nonStaticField = 4+5;
  }
  static public function init(){
     self::$staticFiled = 4+5;
  }
}
-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux