note 75121 added to language.oop5.basic

From: Date: Sun, 13 May 2007 16:03:32 +0000
Subject: note 75121 added to language.oop5.basic
Groups: php.notes 
Request: Send a blank email to php-notes+get-126486@lists.php.net to get a copy of this message
I'm using PHP 5.2.0-8 and it the inline initialization of properties seems to be limited to constant expressions only: <? define ('A', 0x10); define ('B', 0x20); class toto { public $a = A + B; function disp () { echo $this->a; } } $t = new toto (); $t->disp (); ?> will yield "Parse error: syntax error, unexpected '+', expecting ',' or ';'". Not sure if it's a feature or a bug... Anyway, array declarations are ok: <? class toto { public $a = array ('abc', 'def'); function disp () { var_dump ($this->a); } } $t = new toto (); $t->disp (); ?> is fine. ---- Server IP: 69.147.83.197 Probable Submitter: 62.212.114.159 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.basic.php Edit -- https://master.php.net/note/edit/75121 Del: integrated -- https://master.php.net/note/delete/75121/integrated Del: useless -- https://master.php.net/note/delete/75121/useless Del: bad code -- https://master.php.net/note/delete/75121/bad+code Del: spam -- https://master.php.net/note/delete/75121/spam Del: non-english -- https://master.php.net/note/delete/75121/non-english Del: in docs -- https://master.php.net/note/delete/75121/in+docs Del: other reasons-- https://master.php.net/note/delete/75121 Reject -- https://master.php.net/note/reject/75121 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126486) next »