How to use get_object_vars() function to get the properties of the given object in PHP

1 Answer

0 votes
class point {
      var $x, $y;
      
      function point($x, $y) {
         $this->x = $x;
         $this->y = $y;
      }
      
      function setPoint($x, $y) {
         $this->x = $x;
         $this->y = $y;
      }
      
      function getPoint() {
         return array("x" => $this->x, "y" => $this->ys);
      }
   }
    
$p1 = new point(2, 3);
print_r(get_object_vars($p1));
   
/*
run:
 
Array ( [x] => 2 [y] => 3 ) 
    
*/

 



answered Mar 14, 2016 by avibootz
...