Obtaining Variable Names : get_object_vars « Reflection « PHP






Obtaining Variable Names

 
<?
class Shape { 

function __construct($numberOfSides = 3, $sideLength = 10) 
{ 
} 
$square = new Shape(Shape::NUM_SIDES_SQUARE); 

printf("<pre>Shape class variables: %s</pre>", 
print_r(get_class_vars('Shape'), TRUE)); 


printf("<pre>\$square object variables: %s</pre>", 
print_r(get_object_vars($square), TRUE)); 
?>
  
  








Related examples in the same category

1.get_object_vars() function returns an array containing the properties of the attributes.