output:
Class [ <user> class CdProduct extends ShopProduct ] {
@@ D:xampphtdocspopp-code5fullshop.php 53-73
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [0] {
}
- Properties [2] {
Property [ <default> private $playLength ]
Property [ <default> protected $price ]
}
- Methods [10] {
Method [ <user, overwrites ShopProduct, ctor> public method __construct ] {
@@ D:xampphtdocspopp-code5fullshop.php 56 - 61
- Parameters [5] {
Parameter #0 [ <required> $title ]
Parameter #1 [ <required> $firstName ]
Parameter #2 [ <required> $mainName ]
Parameter #3 [ <required> $price ]
Parameter #4 [ <optional> $playLength = 78 ]
}
}
Method [ <user> public method getPlayLength ] {
@@ D:xampphtdocspopp-code5fullshop.php 63 - 65
}
Method [ <user, overwrites ShopProduct, prototype ShopProduct> public method getSummaryLine ] {
@@ D:xampphtdocspopp-code5fullshop.php 67 - 71
}
Method [ <user, inherits ShopProduct> public method getProducerFirstName ] {
@@ D:xampphtdocspopp-code5fullshop.php 17 - 19
}
Method [ <user, inherits ShopProduct> public method getProducerMainName ] {
@@ D:xampphtdocspopp-code5fullshop.php 21 - 23
}
Method [ <user, inherits ShopProduct> public method setDiscount ] {
@@ D:xampphtdocspopp-code5fullshop.php 25 - 27
- Parameters [1] {
Parameter #0 [ <required> $num ]
}
}
Method [ <user, inherits ShopProduct> public method getDiscount ] {
@@ D:xampphtdocspopp-code5fullshop.php 29 - 31
}
Method [ <user, inherits ShopProduct> public method getTitle ] {
@@ D:xampphtdocspopp-code5fullshop.php 33 - 35
}
Method [ <user, inherits ShopProduct> public method getPrice ] {
@@ D:xampphtdocspopp-code5fullshop.php 37 - 39
}
Method [ <user, inherits ShopProduct> public method getProducer ] {
@@ D:xampphtdocspopp-code5fullshop.php 41 - 44
}
}
}
点评:把类看的透彻的一塌糊涂,比var_dump强多了。哪些属性,继承了什么类。类中的方法哪些是自己的,哪些是重写的,哪些是继承的,一目了然。
查看类数据
<?php
require_once("fullshop.php");
function classData( ReflectionClass $class ) {
$details = "";
$name = $class->getName();
if ( $class->isUserDefined() ) {
$details .= "$name is user definedn";
}
if ( $class->isInternal() ) {
$details .= "$name is built-inn";
}
if ( $class->isInterface() ) {
$details .= "$name is interfacen";
}
if ( $class->isAbstract() ) {
$details .= "$name is an abstract classn";
}
if ( $class->isFinal() ) {
$details .= "$name is a final classn";
}
if ( $class->isInstantiable() ) {
$details .= "$name can be instantiatedn";
} else {
$details .= "$name can not be instantiatedn";
}
return $details;
}
$prod_class = new ReflectionClass( 'CdProduct' );
print classData( $prod_class );
?>







