title: Why can var_dump ascertain values of private variables, yet it can't when trying to access a single the property
body: <p>I have an object that is being thrown into the session array, and I want to run a foreach 
  on the items property.</p>
  
  <p>I can't seem to access it.  I see that it's private, but I can't help but wonder why var_dump can show me what the property contains yet I can't read the data as it throws a fatal error?  </p>
  
  <p>I suppose I could do some output buffering and evaluate var_dump as a string if I really have to like <a href="https://stackoverflow.com/questions/139474/how-can-i-capture-the-result-of-var-dump-to-a-string">this</a> but it seems like there should be a better method.  Any ideas how I can access _items?</p>
  
  <p>The object code var_dumped from <code>var_dump($_SESSION['PHPurchaseCart'])</code>:</p>
  
  <pre><code>object(PHPurchaseCart)#191 (4) {
    ["_items:private"]=&gt;
    array(2) {
      [0]=&gt;
      object(PHPurchaseCartItem)#190 (6) {
        ["_productId:private"]=&gt;
        string(2) "80"
        ["_quantity:private"]=&gt;
        int(1)
        ["_optionInfo:private"]=&gt;
        string(20) "Monthly Sponsorship "
        ["_priceDifference:private"]=&gt;
        string(3) ".01"
        ["_customFieldInfo:private"]=&gt;
        NULL
        ["_formEntryIds:private"]=&gt;
        array(0) {
        }
      }
      [1]=&gt;
      object(PHPurchaseCartItem)#189 (6) {
        ["_productId:private"]=&gt;
        string(2) "75"
        ["_quantity:private"]=&gt;
        int(1)
        ["_optionInfo:private"]=&gt;
        string(20) "Monthly Sponsorship "
        ["_priceDifference:private"]=&gt;
        string(3) ".02"
        ["_customFieldInfo:private"]=&gt;
        NULL
        ["_formEntryIds:private"]=&gt;
        array(0) {
        }
      }
    }
    ["_promotion:private"]=&gt;
    NULL
    ["_promoStatus:private"]=&gt;
    int(0)
    ["_shippingMethodId:private"]=&gt;
    NULL
  }
  </code></pre>
  
  <p>Ways I've tried to access it:</p>
  
  <pre><code>$fun = $_SESSION['PHPurchaseCart'];
  var_dump($fun-&gt;_items);
  exit;
  </code></pre>
  
  <p>The above throws a fatal error.</p>