note 120939 added to function.constant
| From: | DawidKrysiak | Date: | Wed, 05 Apr 2017 11:16:25 +0000 |
| Subject: | note 120939 added to function.constant | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-208978@lists.php.net to get a copy of this message | ||
// constant()
It may be obvious (but I haven't found it written literally nowhere), that trying to read the
class constant's value using constant() function, tries to autoload the class in which the
constant is defined (if the class is not already loaded) before generating error. At least in my php
5.5.9.
<?php
$majorPriority = constant('vendor\\package\\SomeClass::MAJOR'); // autoloading here
?>
----
Server IP: 72.52.91.14
Probable Submitter: 213.155.166.101
----
Manual Page -- http://php.net/manual/en/function.constant.php
Edit -- https://master.php.net/note/edit/120939
Del: integrated -- https://master.php.net/note/delete/120939/integrated
Del: useless -- https://master.php.net/note/delete/120939/useless
Del: bad code -- https://master.php.net/note/delete/120939/bad+code
Del: spam -- https://master.php.net/note/delete/120939/spam
Del: non-english -- https://master.php.net/note/delete/120939/non-english
Del: in docs -- https://master.php.net/note/delete/120939/in+docs
Del: other reasons-- https://master.php.net/note/delete/120939
Reject -- https://master.php.net/note/reject/120939
Search -- https://master.php.net/manage/user-notes.php