ReflectionClass::getNamespaceName

(PHP 5 >= 5.3.0)

ReflectionClass::getNamespaceNameGets namespace name

說明

public string ReflectionClass::getNamespaceName ( void )

Gets the namespace name.

Warning

此函式目前沒有參考文件;只有引數列表。

參數

此函式沒有參數。

回傳值

The namespace name.

範例

Example #1 ReflectionClass::getNamespaceName() example

<?php
namespace A\B;

class 
Foo { }

$class = new \ReflectionClass('stdClass');

var_dump($class->inNamespace());
var_dump($class->getName());
var_dump($class->getNamespaceName());
var_dump($class->getShortName());

$class = new \ReflectionClass('A\\B\\Foo');

var_dump($class->inNamespace());
var_dump($class->getName());
var_dump($class->getNamespaceName());
var_dump($class->getShortName());
?>

上例將輸出:

bool(false)
string(8) "stdClass"
string(0) ""
string(8) "stdClass"

bool(true)
string(7) "A\B\Foo"
string(3) "A\B"
string(3) "Foo"

參見

add a note add a note

User Contributed Notes 1 note

up
6
francois
12 years ago
If the object does not belong to a namespace, an empty string is returned
To Top