Search Results
Preface Function Reference Variable and Type Related Extensions Reflection ReflectionClass Change language:
- getMethod
Gets a ReflectionMethod for a class method
- getProperties
Changelog ¶ ... Examples ¶ Example #1...
- getProperty
Gets a ReflectionProperty for a class's property Accessing...
- hasMethod
ReflectionClass::hasMethod (PHP 5 >= 5.1.2, PHP 7, PHP 8)...
- getDocComment
Note that \ReflectionClass::getDocComment() ignores all...
- isSubclassOf
Parameters ¶ class Either the name of the class as string or...
- getConstants
Parameters ¶ filter The optional filter, for filtering...
- getMethods
ReflectionClass::getMethods() sorts the methods by class...
- getMethod
Nov 11, 2013 · Specifically, you can use the ReflectionClass::getShortName method, which gets the name of the class without its namespace. First, you need to build a ReflectionClass instance, and then call the getShortName method of that instance:
- You can do this with reflection. Specifically, you can use the ReflectionClass::getShortName method, which gets the name of the class without its n...
- (new \ReflectionClass($obj))->getShortName(); is the best solution with regards to performance. I was curious which of the provided solutions is th...
- I added substr to the test of https://stackoverflow.com/a/25472778/2386943 and that's the fastet way I could test (CentOS PHP 5.3.3, Ubuntu PHP 5....
- Here is a more easier way of doing this if you are using Laravel PHP framework :
- I use this: basename(str_replace('\\', '/', get_class($object)));
- To get the short name as an one-liner (since PHP 5.4 ): echo (new ReflectionClass($obj))->getShortName();It is a clean approach and reasonable fa...
- I found myself in a unique situation where instanceof could not be used (specifically namespaced traits) and I needed the short name in the most ef...
- You can use explode for separating the namespace and end to get the class name: $ex = explode("\\", get_class($object)); $className = end($ex);
- Yii way \yii\helpers\StringHelper::basename(get_class($model));Yii uses this method in its Gii code generator Method documentation This method is...
Dec 17, 2019 · The Reflection::getShortName () function is an inbuilt function in PHP which is used to return the short name of the specified class, the part without the namespace. Syntax: string Reflection::getShortName( void ) Parameters: This function does not accept any parameters.
Aug 21, 2025 · The getShortName() function is a method of the ReflectionClass class. Its primary purpose is to return the short name of a class, which is essentially the class name without its namespace.
Sep 7, 2025 · ReflectionClass::getShortName (PHP 5 >= 5.3.0, PHP 7, PHP 8) ReflectionClass::getShortName — Gets short name
PHP Manual Gets the short name of the class, the part without the namespace.
People also ask
How do I get a short name from a reflection class?
How to get the name of a reflection class without a namespace?
How many times can a PHP application get a reflection?
ReflectionClass::isInterface — Checks if the class is an interface ReflectionClass::isInternal — Checks if class is defined internally by an extension, or the core
