Java class reflection is widely used and is almost the core of all frameworks, and PHP programmers don't seem to care about reflection. Try to use the Java idea to understand PHP's reflection, and Java basically consistent. Refer to the PHP Manual: http://www.php.net/manual/zh/book.reflection.php.
reflecttest.php:
<?php class Reflecttest { /** * user ID
*/ private $userId; /** * user name */
private $userName; /** * user password */
private $password; /** * user mailbox */
private $email; /** * user QQ number */
private $qq; /** * landing times */
private $loginTimes; public function Reflecttest () { &NBSP;&NBSP;&NBSP;&NBSP} public function __construct ($userId, $userName, $password) {
$this->userid = $userId;
$this->username = $userName;
$this->password = $password; &NBSP;&NBSP;&NBSP;&NBSP} /** * * @return The $userId */ public function GetUserId ( { return $this->userid;  } /** * * @return the $userName */ public function GetUserName () {
return $this->username; &NBSP;&NBSP;&NBSP;&NBSP} &NBSP;&NBSP;&Nbsp; /** * * @return the $password */ public function GetPassword () {
return $this->password; &NBSP;&NBSP;&NBSP;&NBSP} /** *
* @return The $email */ public function GetEmail () {
return $this->email; &NBSP;&NBSP;&NBSP;&NBSP} /** * * @return The $qq */ public function getQq () {
return $this->qq; &NBSP;&NBSP;&NBSP;&NBSP} /** * * @return The $logIntimes */ public function Getlogintimes () {
return $this->logintimes; &NBSP;&NBSP;&NBSP;&NBSP} /** * * @param field_type $userId */ public function Setuserid ($userId) {
$this->userid = $userId; &NBSP;&NBSP;&NBSP;&NBSP} /** * * @param field_type $userName */ public function Setusername ($userName) {
$this->username = $userName; &NBSP;&NBSP;&NBSP;&NBSP} &NBSP;&NBSP;&NBSP /** * * @param field_type $password */ public
function SetPassword ($password) { $this->password = $password; &NBSP;&NBSP;&NBSP;&NBSP} /** * * @param field_type $email */ public function Setemail ($email) {
$this->email = $email; &NBSP;&NBSP;&NBSP;&NBSP} /** * * @param field_type $qq */ public function Setqq ($QQ) {
$this->qq = $qq; &NBSP;&NBSP;&NBSP;&NBSP} /** *
* @param field_type $loginTimes */ public function Setlogintimes ($loginTimes) {
$this->logintimes = $loginTimes; &NBSP;&NBSP;&NBSP;&NBSP}}?>
Test.php:
<?php require_once ' reflecttest.php '; $ref = new Reflecttest ("1", "admin", "admin888"),//instantiated reflecttest echo "
Request http://localhost/php/test/Test.php Output results:
Reflecttest init.
Userid:1
username:admin
password:admin888
Field:
UserId
UserName
Password
Email
QQ
logintimes get
Fields doccomment:
/** * User ID//** * user name//** * User
Password/
/** * User mail Box
//** * User QQ number
//** * Login times
/Get Methods doccomment:
/** * * @return the $USERID/
/** * @return The $userName * * * * * * * * * @return The $password * * * * * @return The $email * * * * */** */** * @return
th E $QQ * * * * * @return The $loginTimes * * * * * * @param field_type $userId * * * * * * * *
@param field_type/** * * *
/** $userName/
/** * * @param field_type $password/
/** * * @param field_type $email/
/** * * @param fiel D_type $qq
//** * * @param field_type $loginTimes
/Get Methods:
reflecttest=
__construct=
getuserid=123
getusername=root
getpassword=123456
getemail=
getqq=
getlogintimes=
setuserid=
setusername=
setpassword=
setemail=
setqq=
setlogintimes= Invoke (set/get) Qq result:
getqq:441637262
jb51.net