note 66870 added to language.oop5.constants
| From: | php-general at lists dot php dot net | Date: | Wed, 31 May 2006 09:03:36 +0000 |
| Subject: | note 66870 added to language.oop5.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-112618@lists.php.net to get a copy of this message | ||
In addition to what "tobias_demuth at web dot de" wrote:
Assigning the return value of a function to a constant does not work. Thus you may assign the return
value of a function to a global constant defintion using "define()" and assign this global
constant to the class constant.
The following example works as expected.
<?php
define("MYTIME", time());
class test {
const time = MYTIME;
}
print test::time;
?>
Will output the current timestamp. Whatsoever: IMHO this is "bad style" and so I suggest
NOT to use this as "workaround".
----
Server IP: 66.163.161.117
Probable Submitter: 213.238.41.61 (proxied: 192.168.168.42)
----
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/66870
Del: integrated -- http://master.php.net/note/delete/66870/integrated
Del: useless -- http://master.php.net/note/delete/66870/useless
Del: bad code -- http://master.php.net/note/delete/66870/bad+code
Del: spam -- http://master.php.net/note/delete/66870/spam
Del: non-english -- http://master.php.net/note/delete/66870/non-english
Del: in docs -- http://master.php.net/note/delete/66870/in+docs
Del: other reasons-- http://master.php.net/note/delete/66870
Reject -- http://master.php.net/note/reject/66870
Search -- http://master.php.net/manage/user-notes.php