note 81072 deleted from language.oop5.constants by cmb
| From: | cmb@php.net | Date: | Wed, 31 Aug 2016 17:16:22 +0000 |
| Subject: | note 81072 deleted from language.oop5.constants by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206441@lists.php.net to get a copy of this message | ||
Note Submitter: riku at helloit dot fi
----
pre 5.3 can refer a class using variable and get constants with:
<?php
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'
?>