ReflectionClass::getNamespaceName

(PHP 5 >= 5.3.0, PHP 7)

ReflectionClass::getNamespaceName锟斤拷取锟斤拷锟斤拷锟秸硷拷锟斤拷锟斤拷锟�

说锟斤拷

public ReflectionClass::getNamespaceName ( void ) : string

锟斤拷取锟斤拷锟斤拷锟秸间(namespace锟斤拷锟斤拷锟斤拷锟狡★拷

Warning

锟斤拷锟斤拷锟斤拷锟斤拷未锟斤拷写锟侥碉拷锟斤拷锟斤拷锟叫诧拷锟斤拷锟叫憋拷

锟斤拷锟斤拷

锟剿猴拷锟斤拷没锟叫诧拷锟斤拷锟斤拷

锟斤拷锟斤拷值

锟斤拷锟斤拷锟秸硷拷锟斤拷锟斤拷啤锟�

锟斤拷锟斤拷

Example #1 ReflectionClass::getNamespaceName() 锟斤拷锟斤拷

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

锟轿硷拷