title: Call external function from within class that accesses private properties
body: <p>I'm trying to make my code a little drier by doing the follow in PHP:</p>
  
  <pre><code>function accessor($obj, $property) {
    return $obj-&gt;$property;
  }
  
  class SomeClass {
    private $variable;
  
    function variable() {
      return accessor($this, 'variable');
    }
  }
  
  $some = new SomeClass;
  echo $some-&gt;variable();
  </code></pre>
  
  <p>The above code throws an error because the external function can't access the private variable. The code is simplified, further coding would make it more useful.</p>
  
  <p>I'm not sure if this is possible but it would sure be nice!</p>