« ReflectionClass::getReflectionConstants
ReflectionClass::getStartLine »

ReflectionClass::getShortName

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

ReflectionClass::getShortName — 短い名前を取得する

説明

public function ReflectionClass::getShortName(): string

名前空間部分を除いた、クラスの短い名前を取得します。

パラメータ

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

戻り値

クラスの短い名前を返します。

例

例1 ReflectionClass::getShortName() の例

<?php
namespace A\B;

class Foo { }

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

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

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

var_dump($function->inNamespace());
var_dump($function->getName());
var_dump($function->getNamespaceName());
var_dump($function->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"

参考

関連キーワード:
ReflectionClass   dump   getShortName   stdClass   getName   inNamespace   getNamespaceName   getReflectionConstants   getStartLine   空間   namespace   参考
関連する関数・ページ:
reflectionclass.getname   reflectionclass.getnamespacename   reflectionclass.innamespace   reflectionclass.getparentclass   reflectionclass.getstartline   reflectionclass.getfilename