note 67816 added to language.oop5.constants
| From: | sw at knip dot pol dot lublin dot pl | Date: | Wed, 05 Jul 2006 19:14:12 +0000 |
| Subject: | note 67816 added to language.oop5.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-114392@lists.php.net to get a copy of this message | ||
It might be obvious,
but I noticed that you can't define an array as a class constant.
Insteed you can define AND initialize an static array variable:
<?php
class AClass {
const an_array = Array (1,2,3,4);
//this WILL NOT work
// and will throw Fatal Error:
//Fatal error: Arrays are not allowed in class constants in...
public static $an_array = Array (1,2,3,4);
//this WILL work
//however, you have no guarantee that it will not be modified outside your class
}
?>
----
Server IP: 83.64.128.68
Probable Submitter: 80.51.226.138
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.oop5.constants.php
Edit -- http://master.php.net/note/edit/67816
Del: integrated -- http://master.php.net/note/delete/67816/integrated
Del: useless -- http://master.php.net/note/delete/67816/useless
Del: bad code -- http://master.php.net/note/delete/67816/bad+code
Del: spam -- http://master.php.net/note/delete/67816/spam
Del: non-english -- http://master.php.net/note/delete/67816/non-english
Del: in docs -- http://master.php.net/note/delete/67816/in+docs
Del: other reasons-- http://master.php.net/note/delete/67816
Reject -- http://master.php.net/note/reject/67816
Search -- http://master.php.net/manage/user-notes.php