PHP |反射类 export()函数
ReflectionClass::export()函数是PHP中的一个内置函数,用于在参数设置为 TRUE 时返回字符串,否则返回 NULL。
句法:
string ReflectionClass::export( mixed $argument, bool $return = FALSE)
参数:该函数接受上面提到的两个参数,如下所述:
- $argument:它保存要导出的用户定义的类。
- $return:它是一个布尔值,TRUE 或 FALSE。
返回值:如果参数已设置为 TRUE,则此函数以字符串形式返回,否则返回 NULL。
下面的程序说明了PHP中的ReflectionClass::export()函数:
方案一:
输出:
string(389) "Class [ class Company ] {
@@ /home/cg/root/7286175/main.php 4-11
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [0] {
}
- Properties [2] {
Property [ public $var1 ]
Property [ public $var2 ]
}
- Methods [1] {
Method [ public method type ] {
@@ /home/cg/root/7286175/main.php 8 - 10
}
}
}
"
方案二:
输出:
Class [ class ReflectionClass implements Reflector ] {
- Constants [3] {
Constant [ integer IS_IMPLICIT_ABSTRACT ] { 16 }
Constant [ integer IS_EXPLICIT_ABSTRACT ] { 32 }
Constant [ integer IS_FINAL ] { 4 }
}
- Static properties [0] {
}
- Static methods [1] {
Method [ static public method export ] {
- Parameters [2] {
Parameter #0 [ $argument ]
Parameter #1 [ $return ]
}
}
}
- Properties [1] {
Property [ public $name ]
}
- Methods [50] {
Method [ final private method __clone ] {
- Parameters [0] {
}
}
Method [ public method __construct ] {
- Parameters [1] {
Parameter #0 [ $argument ]
}
}
Method [ public method __toString ] {
- Parameters [0] {
}
}
Method [ public method getName ] {
- Parameters [0] {
}
}
Method [ public method isInternal ] {
- Parameters [0] {
}
}
Method [ public method isUserDefined ] {
- Parameters [0] {
}
}
Method [ public method isAnonymous ] {
- Parameters [0] {
}
}
Method [ public method isInstantiable ] {
- Parameters [0] {
}
}
Method [ public method isCloneable ] {
- Parameters [0] {
}
}
Method [ public method getFileName ] {
- Parameters [0] {
}
}
Method [ public method getStartLine ] {
- Parameters [0] {
}
}
Method [ public method getEndLine ] {
- Parameters [0] {
}
}
Method [ public method getDocComment ] {
- Parameters [0] {
}
}
Method [ public method getConstructor ] {
- Parameters [0] {
}
}
Method [ public method hasMethod ] {
- Parameters [1] {
Parameter #0 [ $name ]
}
}
Method [ public method getMethod ] {
- Parameters [1] {
Parameter #0 [ $name ]
}
}
Method [ public method getMethods ] {
- Parameters [1] {
Parameter #0 [ $filter ]
}
}
Method [ public method hasProperty ] {
- Parameters [1] {
Parameter #0 [ $name ]
}
}
Method [ public method getProperty ] {
- Parameters [1] {
Parameter #0 [ $name ]
}
}
Method [ public method getProperties ] {
- Parameters [1] {
Parameter #0 [ $filter ]
}
}
Method [ public method hasConstant ] {
- Parameters [1] {
Parameter #0 [ $name ]
}
}
Method [ public method getConstants ] {
- Parameters [0] {
}
}
Method [ public method getConstant ] {
- Parameters [1] {
Parameter #0 [ $name ]
}
}
Method [ public method getInterfaces ] {
- Parameters [0] {
}
}
Method [ public method getInterfaceNames ] {
- Parameters [0] {
}
}
Method [ public method isInterface ] {
- Parameters [0] {
}
}
Method [ public method getTraits ] {
- Parameters [0] {
}
}
Method [ public method getTraitNames ] {
- Parameters [0] {
}
}
Method [ public method getTraitAliases ] {
- Parameters [0] {
}
}
Method [ public method isTrait ] {
- Parameters [0] {
}
}
Method [ public method isAbstract ] {
- Parameters [0] {
}
}
Method [ public method isFinal ] {
- Parameters [0] {
}
}
Method [ public method getModifiers ] {
- Parameters [0] {
}
}
Method [ public method isInstance ] {
- Parameters [1] {
Parameter #0 [ $object ]
}
}
Method [ public method newInstance ] {
- Parameters [1] {
Parameter #0 [ $args ]
}
}
Method [ public method newInstanceWithoutConstructor ] {
- Parameters [0] {
}
}
Method [ public method newInstanceArgs ] {
- Parameters [1] {
Parameter #0 [ array $args ]
}
}
Method [ public method getParentClass ] {
- Parameters [0] {
}
}
Method [ public method isSubclassOf ] {
- Parameters [1] {
Parameter #0 [ $class ]
}
}
Method [ public method getStaticProperties ] {
- Parameters [0] {
}
}
Method [ public method getStaticPropertyValue ] {
- Parameters [2] {
Parameter #0 [ $name ]
Parameter #1 [ $default ]
}
}
Method [ public method setStaticPropertyValue ] {
- Parameters [2] {
Parameter #0 [ $name ]
Parameter #1 [ $value ]
}
}
Method [ public method getDefaultProperties ] {
- Parameters [0] {
}
}
Method [ public method isIterateable ] {
- Parameters [0] {
}
}
Method [ public method implementsInterface ] {
- Parameters [1] {
Parameter #0 [ $interface ]
}
}
Method [ public method getExtension ] {
- Parameters [0] {
}
}
Method [ public method getExtensionName ] {
- Parameters [0] {
}
}
Method [ public method inNamespace ] {
- Parameters [0] {
}
}
Method [ public method getNamespaceName ] {
- Parameters [0] {
}
}
Method [ public method getShortName ] {
- Parameters [0] {
}
}
}
}
NULL
参考: https://secure。 PHP.net/manual/en/reflectionclass.export。 PHP