Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 25th, 2012  |  syntax: None  |  size: 0.69 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using ReflectionClass to read the class Properties
  2. class Certificate {
  3.       private $isin;
  4.       private $tradingMarket;
  5.       private $currency;
  6.       private $issuer;
  7.       private $issuingPrice;
  8.       private $currentPrice;
  9.       private $priceHistory;
  10.       private $documents;
  11.       private $serializer;
  12. }
  13.        
  14. function getProperties($object) {
  15.     $ref = new ReflectionClass(get_class($object));
  16.     foreach ($reg->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED | ReflectionProperty::IS_PRIVATE) as $prop) {
  17.         if (is_object($prop->getValue($object)) getProperties($prop->getValue($object));
  18.         else echo get_class($object)." => ".$prop->getName();
  19.     }
  20. }