Content · Web Development · PHP

PHP ReflectionExtension::info() Method: Usage and Examples

Prints the extension's detailed configuration information.

1 views Published Oct 17, 2026 Updated Oct 17, 2026 admin

When building tools that inspect PHP code, ReflectionExtension::info() helps answer a focused question: prints the extension's detailed configuration information.

Reflection is useful in framework tooling, dependency injection, testing, code inspection and debugging.

What Is ReflectionExtension::info()?


Prints the extension's detailed configuration information.

Its method signature is:

public function info(): void

This method has no required arguments.

Return value: void

Example 1: Inspect a loaded extension


Start with a self-contained PHP declaration and inspect the method result.

<?php

declare(strict_types=1);

$extensionReflection = new ReflectionExtension("json");

$result = $extensionReflection->info();
// info() prints its report directly.

Output:

json

json support => enabled

Explanation: Prints the extension's detailed configuration information.

Example 2: Compare extension metadata


Next, change the reflected declaration or parameter to observe a related situation.

<?php

declare(strict_types=1);

$extensionReflection = new ReflectionExtension("date");

$result = $extensionReflection->info();
// info() prints its report directly.

// Check the returned value type before using the result.
echo "\nResult type: " . get_debug_type($result);

Output:

date

date/time support => enabled
timelib version => 2022.17
"Olson" Timezone Database Version => 0.system
Timezone Database => internal
Default timezone => UTC

Directive => Local Value => Master Value
date.timezone => UTC => UTC
date.default_latitude => 31.7667 => 31.7667
date.default_longitude => 35.2333 => 35.2333
date.sunset_zenith => 90.833333 => 90.833333
date.sunrise_zenith => 90.833333 => 90.833333

Result type: null

Explanation: It writes output directly and may disclose configuration; do not expose it on a public page.

Practical Example: Use extension information for diagnostics


This final case shows how the same API can be used when inspecting application definitions.

<?php

declare(strict_types=1);

$extensionReflection = new ReflectionExtension("standard");

$result = $extensionReflection->info();
// info() prints its report directly.

// Use the reflection result in a simple decision.
if (is_bool($result)) {
    echo "\nStatus: " . ($result ? "yes" : "no");
} elseif (is_array($result)) {
    echo "\nEntries: " . count($result);
} elseif ($result === null) {
    echo "\nNo value returned";
} else {
    echo "\nReflection result available";
}

The exact output or reflected object details depend on the declaration and PHP runtime. Inspect the returned value before using it in application logic.

Explanation: getINIEntries reads structured configuration without printing a report.

Important Behavior and Edge Cases


  • It writes output directly and may disclose configuration; do not expose it on a public page.
  • getINIEntries reads structured configuration without printing a report.
  • Reflection describes declarations and runtime state; requesting metadata does not automatically validate or sanitize application input.

Comparison With Related Approaches


ApproachWhen to Use It
ReflectionExtension::info()Prints the extension's detailed configuration information.
Related APIgetINIEntries reads structured configuration without printing a report.

Common Beginner Mistakes


MistakeCorrect Approach
Ignoring this condition: It writes output directly and may disclose configuration; do not expose it on a public page.Handle the specific limitation: It writes output directly and may disclose configuration; do not expose it on a public page.
Confusing this method with Related APIgetINIEntries reads structured configuration without printing a report.

Key Takeaways


  • Prints the extension's detailed configuration information.
  • It writes output directly and may disclose configuration; do not expose it on a public page.
  • getINIEntries reads structured configuration without printing a report.

Use ReflectionExtension::info() when you need the precise metadata or behavior demonstrated above. Keep the target declaration and relevant PHP version in mind when adapting the examples.

Share this resourceSend this page to someone who may find it useful.