首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

ReflectionClass::export

(PHP 5, PHP 7)

ReflectionClass::export - 导出一个类

描述

代码语言:javascript
复制
public static string ReflectionClass::export ( mixed $argument [, bool $return = false ] )

导出反射类。

参数

argument

反映出口。

return

设置为TRUE将返回出口,而不是释放出口。设置为FALSE(默认)会做相反的事情。

返回值

如果return参数设置为TRUE,则导出以字符串形式返回,否则返回NULL

示例

Example#1 ReflectionClass::export()的基本用法

代码语言:javascript
复制
<?php
class?Apple?{
????public?$var1;
????public?$var2?=?'Orange';

????public?function?type()?{
????????return?'Apple';
????}
}
ReflectionClass::export('Apple');
?>

上面的例子会输出类似于:

代码语言:javascript
复制
Class [ <user> class Apple ] {
  @@ php shell code 1-8

  - Constants [0] {
  }

  - Static properties [0] {
  }

  - Static methods [0] {
  }

  - Properties [2] {
    Property [ <default> public $var1 ]
    Property [ <default> public $var2 ]
  }

  - Methods [1] {
    Method [ <user> public method type ] {
      @@ php shell code 5 - 7
    }
  }
}

另请参阅

  • ReflectionClass::getName() - 获取类名

← ReflectionClass::__construct

ReflectionClass::getConstant →

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com