php8.5
Home/ Manual/ reflection / reflectionconstant/ ReflectionConstant::getShortName

ReflectionConstant::getShortName

PHP function Edit on GitHub ✎

(PHP 8 >= 8.4.0)

Gets short name

Description

ReflectionConstant::getShortName(): string

Gets the short name of the constant, the part without the namespace.

Parameters Parameters

Return Values

The short name of the constant.

Examples

ReflectionConstant::getShortName example

php
<?php
namespace Foo;

const BAR = 'bar';

echo (new \ReflectionConstant('Foo\BAR'))->getShortName();
?>

The above example will output:

output
BAR

See Also

  • ReflectionConstant::getName

Source: reference/reflection/reflectionconstant/getshortname.xml · from the official PHP manual (php/doc-en)