title: PHP properties with get/set functions
body: <p>One of the handy features of other languages is the ability to create get and set methods for properties.  In trying to find a good way to duplicate this functionality in PHP, I stumbled across this:  <a href="http://www.php.net/manual/en/language.oop5.magic.php#98442" rel="nofollow">http://www.php.net/manual/en/language.oop5.magic.php#98442</a></p>
  
  <p>Here is my breakdown of that class:</p>
  
  <pre><code>&lt;?php
  
  class ObjectWithGetSetProperties {
  
      public function __get($varName) {
          if (method_exists($this,$MethodName='get_'.$varName)) {
              return $this-&gt;$MethodName();
          } else {
              trigger_error($varName.' is not avaliable .',E_USER_ERROR);
          }
      }
  
      public function __set($varName,$value) {
          if (method_exists($this,$MethodName='set_'.$varName)) {
              return $this-&gt;$MethodName($value);
          } else {
              trigger_error($varName.' is not avaliable .',E_USER_ERROR);
          }
      }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>My plan was to extend this class and define the appropriate <code>get_someproperty()</code> and <code>set_someproperty()</code> in this extended class.</p>
  
  <pre><code>&lt;?php
  class SomeNewClass extends ObjectWithGetSetProperties {
      protected $_someproperty;
      public function get_someproperty() {
          return $this-&gt;_someproperty;
      }
  }
  ?&gt;
  </code></pre>
  
  <p>The trouble is, the base class of <code>ObjectWithGetSetProperties</code> is unable to see my method <code>get_someproperty()</code> in <code>SomeNewClass</code>.  I always get the error, "key is not available".</p>
  
  <p>Is there any way to resolve this, allowing the base class of <code>ObjectWithGetSetProperties</code> to work, or will I have to create those <code>__get()</code> and <code>__set()</code> magic methods in each class?</p>