note 124670 added to language.constants
| From: | (AbuTaleb) | Date: | Sat, 01 Feb 2020 14:21:32 +0000 |
| Subject: | note 124670 added to language.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-213985@lists.php.net to get a copy of this message | ||
define('MYKEY', 'The value is from outside of class');
class Abc{
const MAX = 10;
public function __construct(){
define('TEST', 'hello world! '); // using define function in class
constructor
}
public function getOutput(){
echo TEST . MYKEY . PHP_EOL; // accessing constants from outside of class
}
}
$obj = new Abc(); // define function will call
$obj->getOutput(); // hello world! The value is from outside of class
echo Abc::MAX . PHP_EOL; // 10 - accessing constant using scope resolution
echo TEST; // hello world! Because the constants is defined while constructor call
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.195 (proxied: 103.135.232.27)
----
Manual Page -- http://php.net/manual/en/language.constants.php
Edit -- https://master.php.net/note/edit/124670
Del: integrated -- https://master.php.net/note/delete/124670/integrated
Del: useless -- https://master.php.net/note/delete/124670/useless
Del: bad code -- https://master.php.net/note/delete/124670/bad+code
Del: spam -- https://master.php.net/note/delete/124670/spam
Del: non-english -- https://master.php.net/note/delete/124670/non-english
Del: in docs -- https://master.php.net/note/delete/124670/in+docs
Del: other reasons-- https://master.php.net/note/delete/124670
Reject -- https://master.php.net/note/reject/124670
Search -- https://master.php.net/manage/user-notes.php