Re: [PHP] Has this always been the case?

[email protected] (shiplu)
Newsgroups php.general
Message-ID <CADO5mDBv4E_FsgD+2N2J_i54AxWS5U0mmvg+3R+17OOGRmo=Lw@mail.gmail.com>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.