note 120936 added to language.oop5.autoload
| From: | DawidKrysiak | Date: | Wed, 05 Apr 2017 10:58:47 +0000 |
| Subject: | note 120936 added to language.oop5.autoload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-208975@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.autoload.php
Edit -- https://master.php.net/note/edit/120936
Del: integrated -- https://master.php.net/note/delete/120936/integrated
Del: useless -- https://master.php.net/note/delete/120936/useless
Del: bad code -- https://master.php.net/note/delete/120936/bad+code
Del: spam -- https://master.php.net/note/delete/120936/spam
Del: non-english -- https://master.php.net/note/delete/120936/non-english
Del: in docs -- https://master.php.net/note/delete/120936/in+docs
Del: other reasons-- https://master.php.net/note/delete/120936
Reject -- https://master.php.net/note/reject/120936
Search -- https://master.php.net/manage/user-notes.php