getNamespaceName
Description
The getNamespaceName of ReflectionConstant for PHP gets the namespace name.
Syntax
public ReflectionConstant::getNamespaceName(): string
Return
Returns the namespace name, or an empty string for the global namespace.
Examples
1 · void
<?
namespace Mynamespace
{
const MYCONSTANT = 'value';
$reflectionconstant = new \ReflectionConstant('Mynamespace\MYCONSTANT');
$return = $reflectionconstant->getNamespaceName();
echo $return;
}
Mynamespace
2 · global
<?
namespace
{
const MYCONSTANT = 'value';
$reflectionconstant = new \ReflectionConstant('MYCONSTANT');
$return = $reflectionconstant->getNamespaceName();
var_dump($return);
}
string(0) ""