Voting

: nine plus zero?
(Example: nine)

The Note You're Voting On

t dot kmieliauskas at gmail dot com
10 years ago
If you are referencing class constant (either using namespaces or not, because one day you may want to start using them), you'll have the least headaches when doing it like this:

<?php
class Foo {
const
BAR = 42;
}
?>
<?php
namespace Baz;
use
\Foo as F;

echo
constant(F::class.'::BAR');
?>

since F::class will be dereferenced to whatever namespace shortcuts you are using (and those are way easier to refactor for IDE than just plain strings with hardcoded namespaces in string literals)

<< Back to user notes page

To Top