PHP Reflectionclass,phpreflectionclass
1 Php
2 /* * 3 * @desc Test Reflectionclass 4 * @author songweiqing 5 * @create_time 2015-01-7 6 * 7 */ 8 class test{ 9 Public $attr 1= ' ATTR1 '
; Ten protected $attr 2= ' ATTR2 '
; One Private $attr 3= ' ATTR3 '
; A ConstATTR4 = ' I AM the ATTRIBUTE 4 '
; - Public Static $attr 5= ' ATTR5 '
; - the Public function __construct () { - -Self::
$attr 5= ' I Love You Baby '
; - } + Public function getAttr1 () { - + Echo $this-
attr1; A } at // Get Property 2 - protected function getAttr2 () { - - Echo $this-
attr2; - } - /* * in * @desc Get Properties 3 - * @return String to */ + Private function GetAttr3 () { - Echo $this-
ATTR3; the } * $ Public Static function GETATTR5 () { Panax Notoginseng EchoSelf::
$attr 5 ; - } the } + A $reflection=
NewReflectionclass (' Test '
); the // Var_dump ($reflection->getname ());//Get the Class name GetName (); + //var_dump ($reflection->getconstant ("ATTR4"));//Gets the specified constant name - //var_dump ($reflection->getconstants ());//Get a set of constant names $ //var_dump ($reflection->getconstructor ());//Get constructor, no constructor returns null $ //var_dump ($reflection->getdefaultproperties ());//Gets the default property, and the constant property does not include - //var_dump ($reflection->getdoccomment ());//Gets a comment for the class, ignores it, and does not return false for comments in the class method - //var_dump ($reflection->getendline ());//Gets the last row of rows in the class the //var_dump ($reflection->getfilename ());//Gets the class name of the definition class - //var_dump ($reflection->getmethods ());//Get methods in all classes Wuyi //var_dump ($reflection->getproperties ());//Get all properties, without constant properties the //$instance = $reflection->newinstanceargs ();//Instantiate this class of reflection - //$instance = $reflection->newinstance (' Test '); Instantiate the specified class View Code
http://www.bkjia.com/PHPjc/939251.html www.bkjia.com true http://www.bkjia.com/PHPjc/939251.html techarticle php reflectionclass,phpreflectionclass 1 php 2/* * 3 * @desc Test reflectionclass 4 * @author songweiqing 5 * @crea Te_time 2015-01-7 6 * 7 */8 class test{9 public $attr 1 = ' ...