title: OOP PHP, getters and setters using magic methods
body: <p>What strategies are available to creating accessors and mutators for a PHP class' private members? Is this suggestion good: <a href="http://cormacscode.wordpress.com/2009/01/22/read-only-object-variables-in-php-using-magic-methods/" rel="nofollow">http://cormacscode.wordpress.com/2009/01/22/read-only-object-variables-in-php-using-magic-methods/</a></p>
  
  <pre><code>&lt;?php
  class classWithReadOnlyVar
  {
      private $readOnlyVar;
  
      public function __get($varName)
      {
          return $this-&gt;$varName;
      }
  
      public function __set($varName,$varValue)
      {
      }
  }
  </code></pre>
  
  <p>What if some members needed a private, public, or protected property method?</p>