note 81072 added to language.oop5.constants
| From: | riku at helloit dot fi | Date: | Wed, 13 Feb 2008 11:24:43 +0000 |
| Subject: | note 81072 added to language.oop5.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136108@lists.php.net to get a copy of this message | ||
pre 5.3 can refer a class using variable and get constants with:
function get_class_const($class, $const){
return constant(sprintf('%s::%s', $class, $const));
}
class Foo{
const BAR = 'foobar';
}
$class = 'Foo';
echo get_class_const($class, 'BAR');
//'foobar'
----
Server IP: 69.147.83.197
Probable Submitter: 88.112.255.187
----
Manual Page -- http://www.php.net/manual/en/language.oop5.constants.php
Edit -- https://master.php.net/note/edit/81072
Del: integrated -- https://master.php.net/note/delete/81072/integrated
Del: useless -- https://master.php.net/note/delete/81072/useless
Del: bad code -- https://master.php.net/note/delete/81072/bad+code
Del: spam -- https://master.php.net/note/delete/81072/spam
Del: non-english -- https://master.php.net/note/delete/81072/non-english
Del: in docs -- https://master.php.net/note/delete/81072/in+docs
Del: other reasons-- https://master.php.net/note/delete/81072
Reject -- https://master.php.net/note/reject/81072
Search -- https://master.php.net/manage/user-notes.php