note 120937 added to language.oop5.constants
| From: | DawidKrysiak | Date: | Wed, 05 Apr 2017 11:03:51 +0000 |
| Subject: | note 120937 added to language.oop5.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-208976@lists.php.net to get a copy of this message | ||
It may be obvious (but I haven't found it written literally nowhere), that checking if the
class constant is defined (using defined() function) or reading it's contents (using constant()
function), also tries to autoload the class in which the constant is defined (if the class is not
already loaded). At least in my php 5.5.9.
<?php
if (defined('vendor\\package\\SomeClass::MAJOR')) { // autoloading here
echo 'Oh, I know how to recognize major stuff!'. PHP_EOL;
}
$loadedState = constant('vendor\\package\\OtherClass::LOADED'); // autoloading here
?>
----
Server IP: 72.52.91.14
Probable Submitter: 213.155.166.101
----
Manual Page -- http://php.net/manual/en/language.oop5.constants.php
Edit -- https://master.php.net/note/edit/120937
Del: integrated -- https://master.php.net/note/delete/120937/integrated
Del: useless -- https://master.php.net/note/delete/120937/useless
Del: bad code -- https://master.php.net/note/delete/120937/bad+code
Del: spam -- https://master.php.net/note/delete/120937/spam
Del: non-english -- https://master.php.net/note/delete/120937/non-english
Del: in docs -- https://master.php.net/note/delete/120937/in+docs
Del: other reasons-- https://master.php.net/note/delete/120937
Reject -- https://master.php.net/note/reject/120937
Search -- https://master.php.net/manage/user-notes.php