OO PHP - 从类中检索所有属性

时间:2012-02-07 15:56:09

标签: php oop class attributes

是否有一个函数/方法从类中检索所有属性?比如下面我班级的所有属性:

class plantOfTheMonth {

   //Declare which centre(s) are being used
    private $centre = "";

    //Declare the attributes of the current Plant Of The Month
    private $name = "";
    private $latinName = "";
    private $image = "";
    private $imageAlt = "";
    private $imageLink = "";
    private $strapLine = "";
    private $description = "";
    private $color = "";
    private $centres = "";

    //Declare variables for error handling
    private $issue = "";
    private $issueCode = "";

}

2 个答案:

答案 0 :(得分:4)

答案 1 :(得分:0)

foreach也将完成这项工作,it iterates trough the visible class properties