php8.5
Home/ Manual/ reflection / reflectionclass/ ReflectionClass::getExtension

ReflectionClass::getExtension

PHP function Edit on GitHub ✎

(PHP 5, PHP 7, PHP 8)

Gets a ReflectionExtension object for the extension which defined the class

Description

ReflectionClass::getExtension(): ReflectionExtension|null

Gets a ReflectionExtension object for the extension which defined the class.

Parameters Parameters

Return Values

A ReflectionExtension object representing the extension which defined the class, or null for user-defined classes.

Examples

Basic usage of ReflectionClass::getExtension

php
<?php
$class = new ReflectionClass('ReflectionClass');
$extension = $class->getExtension();
var_dump($extension);
?>

The above example will output:

output
object(ReflectionExtension)#2 (1) {
  ["name"]=>
  string(10) "Reflection"
}

See Also

  • ReflectionClass::getExtensionName

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