ReflectionConstant::getNamespaceName

Gets namespace name

Description

public string ReflectionConstant::getNamespaceName()

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) ""