Mega Code Archive

 
Categories / Php / Reflection
 

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));  ?>