note 84975 added to function.get-defined-constants
| From: | Bob at osu1 dot php dot net | Date: | Fri, 08 Aug 2008 04:50:34 +0000 |
| Subject: | note 84975 added to function.get-defined-constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143293@lists.php.net to get a copy of this message | ||
Add this method to your class definition if you want an array of class constants
(get_defined_constants doesn't work with class constants as Peter P said above):
<?php
public function get_class_constants()
{
$reflect = new ReflectionClass(get_class($this));
return $reflect->getConstants());
}
?>
You could also override stdObject with it so that all your classes have this method
----
Server IP: 203.88.112.190
Probable Submitter: 58.96.34.67
----
Manual Page -- http://www.php.net/manual/en/function.get-defined-constants.php
Edit -- https://master.php.net/note/edit/84975
Del: integrated -- https://master.php.net/note/delete/84975/integrated
Del: useless -- https://master.php.net/note/delete/84975/useless
Del: bad code -- https://master.php.net/note/delete/84975/bad+code
Del: spam -- https://master.php.net/note/delete/84975/spam
Del: non-english -- https://master.php.net/note/delete/84975/non-english
Del: in docs -- https://master.php.net/note/delete/84975/in+docs
Del: other reasons-- https://master.php.net/note/delete/84975
Reject -- https://master.php.net/note/reject/84975
Search -- https://master.php.net/manage/user-notes.php