这篇文章主要介绍了PHP中的reflection反射机制测试例子,从本文可以学到一些反射的使用方法,需要的朋友可以参考下
Java类反射应用得非常广泛几乎是所有框架的最核心部分,,PHP程序员似乎从不关心反射。尝试着用java的思想去理解php的反射,跟java基本上基本一致。参考了php手册:。
ReflectTest.php:
userId = $userId; $this->userName = $userName; $this->password = $password; } /** * * @return the $userId */ public function getUserId() { return $this->userId; } /** * * @return the $userName */ public function getUserName() { return $this->userName; } /** * * @return the $password */ public function getPassword() { return $this->password; } /** * * @return the $email */ public function getEmail() { return $this->email; } /** * * @return the $qq */ public function getQq() { return $this->qq; } /** * * @return the $loginTimes */ public function getLoginTimes() { return $this->loginTimes; } /** * * @param field_type $userId */ public function setUserId($userId) { $this->userId = $userId; } /** * * @param field_type $userName */ public function setUserName($userName) { $this->userName = $userName; } /** * * @param field_type $password */ public function setPassword($password) { $this->password = $password; } /** * * @param field_type $email */ public function setEmail($email) { $this->email = $email; } /** * * @param field_type $qq */ public function setQq($qq) { $this->qq = $qq; } /** * * @param field_type $loginTimes */ public function setLoginTimes($loginTimes) { $this->loginTimes = $loginTimes; } } ?>
Test.php: