PHP 8.5.0 Alpha 4 available for testing

ReflectionConstant::getNamespaceName

(PHP 8 >= 8.4.0)

ReflectionConstant::getNamespaceName名前空間名を取得する

説明

public ReflectionConstant::getNamespaceName(): string

定数の名前空間名を取得します。

パラメータ

この関数にはパラメータはありません。

戻り値

名前空間名を返します。グローバル名前空間の場合は空文字列を返します。

例1 ReflectionConstant::getNamespaceName() の例

<?php
namespace Foo {
const
BAR = 'bar';
var_dump((new \ReflectionConstant('Foo\BAR'))->getNamespaceName());
}

namespace {
const
BAR = 'bar';
var_dump((new \ReflectionConstant('BAR'))->getNamespaceName());
}
?>

上の例の出力は以下となります。

string(3) "Foo"
string(0) ""
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top