PHP 8.5.0 Alpha 1 available for testing

Voting

: zero minus zero?
(Example: nine)

The Note You're Voting On

Richard J. Turner
12 years ago
As of PHP 5.4.6 constant() pays no attention to any namespace aliases that might be defined in the file in which it's used. I.e. constant() always behaves as if it is called from the global namespace. This means that the following will not work:

<?php
class Foo {
const
BAR = 42;
}
?>

<?php
namespace Baz;

use
\Foo as F;

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

However, calling constant('Foo::BAR') will work as expected.

<< Back to user notes page

To Top