略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: ReflectionExtension

2024-11-14

ReflectionExtension 类

(PHP 5, PHP 7, PHP 8)

简介

ReflectionExtension 报告了一个扩展(extension)的有关信息。

类摘要

class ReflectionExtension implements Reflector {
/* 属性 */
public $name;
/* 方法 */
final private __clone(): void
public __construct(string $name)
public static export(string $name, string $return = false): string
public getClasses(): array
public getClassNames(): array
public getConstants(): array
public getDependencies(): array
public getFunctions(): array
public getINIEntries(): array
public getName(): string
public getVersion(): string
public info(): void
public isPersistent(): void
public isTemporary(): void
public __toString(): string
}

属性

name

扩展的名称,和 ReflectionExtension::getName() 方法所返回的一样。

目录

add a noteadd a note

User Contributed Notes 2 notes

up
3
Lubaev.K
9 years ago
<?php
// The demonstration for the class "ReflectionExtension".

function REData(ReflectionExtension $re, $return=false) {

   
defined('UNDEFINED') || define('UNDEFINED','%undefined%');
   
$_data = [];

   
$_data['getName:'] = $re->getName() ?: UNDEFINED;
   
$_data['getVersion:'] = $re->getVersion() ?: UNDEFINED;
   
$_data['info:'] = $re->info() ?: UNDEFINED;
   
$_data['getClassName:'] = PHP_EOL.implode(", ",$re->getClassNames()) ?: UNDEFINED;    
    foreach (
$re->getConstants() as $key => $value) $_data['getConstants:'] .= "\n{$key}:={$value}";
   
$_data['getDependencies:'] = $re->getDependencies() ?: UNDEFINED;
   
$_data['getFunctions:'] = PHP_EOL.implode(", ",array_keys($re->getFunctions())) ?: UNDEFINED;
   
$_data['getINIEntries:'] = $re->getINIEntries() ?: UNDEFINED;
   
$_data['isPersistent:'] = $re->isPersistent() ?: UNDEFINED;
   
$_data['isTemporary:'] = $re->isTemporary() ?: UNDEFINED;

    return
print_r($_data, $return);
}

REData( new ReflectionExtension( 'Reflection' ) );
REData( new ReflectionExtension( 'zlib' ) );

// Reflection
// Reflection => enabled
// Version => $Id: 60f1e547a6dd00239162151e701566debdcee660 $
/*
Array
(
    [getName:] => Reflection
    [getVersion:] => $Id: 60f1e547a6dd00239162151e701566debdcee660 $
    [info:] => %undefined%
    [getClassName:] =>
ReflectionException, Reflection, Reflector, ReflectionFunctionAbstract, Reflecti
onFunction, ReflectionParameter, ReflectionMethod, ReflectionClass, ReflectionOb
ject, ReflectionProperty, ReflectionExtension, ReflectionZendExtension
    [getDependencies:] => %undefined%
    [getFunctions:] =>

    [getINIEntries:] => %undefined%
    [isPersistent:] => 1
    [isTemporary:] => %undefined%
)
*/
// zlib
// ZLib Support => enabled
// Stream Wrapper => compress.zlib://
// Stream Filter => zlib.inflate, zlib.deflate
// Compiled Version => 1.2.7
// Linked Version => 1.2.7
// Directive => Local Value => Master Value
// zlib.output_compression => Off => Off
// zlib.output_compression_level => -1 => -1
// zlib.output_handler => no value => no value
/*
Array
(
    [getName:] => zlib
    [getVersion:] => 2.0
    [info:] => %undefined%
    [getClassName:] =>

    [getConstants:] =>
FORCE_GZIP:=31
FORCE_DEFLATE:=15
ZLIB_ENCODING_RAW:=-15
ZLIB_ENCODING_GZIP:=31
ZLIB_ENCODING_DEFLATE:=15
    [getDependencies:] => %undefined%
    [getFunctions:] =>
readgzfile, gzrewind, gzclose, gzeof, gzgetc, gzgets, gzgetss, gzread, gzopen, g
zpassthru, gzseek, gztell, gzwrite, gzputs, gzfile, gzcompress, gzuncompress, gz
deflate, gzinflate, gzencode, gzdecode, zlib_encode, zlib_decode, zlib_get_codin
g_type, ob_gzhandler
    [getINIEntries:] => Array
        (
            [zlib.output_compression] =>
            [zlib.output_compression_level] => -1
            [zlib.output_handler] =>
        )

    [isPersistent:] => 1
    [isTemporary:] => %undefined%
)
*/
up
1
Anonymous
6 years ago
<?php
 
// Create an instance of the ReflectionProperty class
 
$ext= new ReflectionExtension('standard');

 
// Print out basic information
 
printf(
     
"Name        : %s\n".
     
"Version     : %s\n".
     
"Functions   : [%d] %s\n".
     
"Constants   : [%d] %s\n".
     
"INI entries : [%d] %s\n",
     
$ext->getName(),
     
$ext->getVersion() ? $ext->getVersion() : 'NO_VERSION',
     
sizeof($ext->getFunctions()),
     
var_export($ext->getFunctions(), 1),
     
sizeof($ext->getConstants()),
     
var_export($ext->getConstants(), 1),
     
sizeof($ext->getINIEntries()),
     
var_export($ext->getINIEntries(), 1)
  );
?>

官方地址:https://www.php.net/manual/en/class.reflectionextension.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3