ReflectionConstant::getNamespaceName
(PHP 8 >= 8.4.0)
ReflectionConstant::getNamespaceName — Gets namespace name
Description
Gets the namespace name of the constant.
Parameters
This function has no parameters.
Return Values
The namespace name, or an empty string for the global namespace.
Examples
Example #1 ReflectionConstant::getNamespaceName() example
<?php
namespace Foo {
const BAR = 'bar';
var_dump((new \ReflectionConstant('Foo\BAR'))->getNamespaceName());
}
namespace {
const BAR = 'bar';
var_dump((new \ReflectionConstant('BAR'))->getNamespaceName());
}
?>The above example will output:
string(3) "Foo" string(0) ""
↑ and ↓ to navigate • Enter to select • Esc to close • / to open