Private $pagebarnum =10; $this->pagebarnum = $array [' page_name ']; $this->set (' Pagebarnum ', $array [' Page_ Name ']);/** * Sets the value of the variable name specified in the class, and if the amount of change does not belong to this class, throw a exception * @param unknown $var * @param unknown $value */ function set ($var, $value) { if (In_array ($var, Get_object_vars ($this))) { $this, $var = $value ; } else{ $this->error (__function__, $var. "Does not belong to pb_page!"); } }
$this->pagebarnum = $array [' page_name ']; and $this->set (' Pagebarnum ', $array [' page_name ']); What is the difference between assignments, clearly I have defined the $pagebarnum in the class, I use set to assign value and this is necessary?
Reply to discussion (solution)
Variable initialization and adjustment of course it is necessary to assume that you need a page parameter is 10, a page parameter is 5, you do two classes?
Variable initialization and adjustment of course it is necessary to assume that you need a page parameter is 10, a page parameter is 5, you do two classes?
Instantiating a class to pass in can be achieved, but what is not understood is directly with $this->pagebarnum = $array [' page_name ']; and the Set method first check the existence of the variable is not what is the difference? Pagebarnum has been defined to check what it means when I create a class.
$this->pagebarnum = $array [' page_name '];
$this->set (' Pagebarnum ', $array [' page_name ']);
The difference is that the latter does not assign a value to a nonexistent property pagebarnum, which creates a public Pagebarnum property pagebarnum the non-existent property