title: PHP print_r and static member
body: <p>I've got an instance of a <em>DB</em> object that's passed to a <em>Session</em> object, because the <em>Session</em> object has several methods that make use of <em>DB</em> object to execute SQL statements I had plan to store this <em>DB</em> object in <em>Session</em> object property.</p>
  
  <p>Through testing I found that <code>print_r</code> exposed the <em>DB</em> object stored in the <em>Session</em> object property; included in the output was the db user/password.</p>
  
  <p>So my idea was to store the <em>DB</em> object in a private static member, to prevent this info from being disclosed whenever <code>print_r</code> is called on the <em>Session</em> object.</p>
  
  <p>Is this acceptable, or just plain bad use of static member?</p>
  
  <p>What's recommended way of preventing private object property from disclosed during <code>print_r</code>?</p>
  
  <p>Here's code sample.</p>
  
  <p><strong>Before:</strong></p>
  
  <pre><code>class Session 
  {
  
      public __construct(DB $db)
      {
          $this-&gt;db = $db;
      }
  
  }
  </code></pre>
  
  <p><strong>After:</strong></p>
  
  <pre><code>class Session
  {
  
      private static $db;
  
      pubic __construct(DB $db)
      {
          self::$db = $db;
      }
  
  }
  </code></pre>