array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), 'this' => array ( 0 => 'reflectionclass.getshortname.php', 1 => 'ReflectionClass::getShortName', ), 'up' => array ( 0 => 'class.reflectionclass.php', 1 => 'ReflectionClass', ), 'prev' => array ( 0 => 'reflectionclass.getreflectionconstants.php', 1 => 'ReflectionClass::getReflectionConstants', ), 'next' => array ( 0 => 'reflectionclass.getstartline.php', 1 => 'ReflectionClass::getStartLine', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'fr', 'path' => 'reference/reflection/reflectionclass/getshortname.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
ReflectionClass::getShortName — Récupère le nom court d'une classe
Récupère le nom court d'une classe, c'est-à-dire, la partie sans l'espace de noms.
Cette fonction ne contient aucun paramètre.
Le nom court de la classe.
Exemple #1 Exemple avec 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());
?>
L'exemple ci-dessus va afficher :
bool(false) string(8) "stdClass" string(0) "" string(8) "stdClass" bool(true) string(7) "A\B\Foo" string(3) "A\B" string(3) "Foo"