title: Adding a PHP anonymous function to an object
body: <p>Is it possible to add an anonymous function to an object, and call it within the object.  See below for example code.  <a href="https://stackoverflow.com/questions/4535330/calling-closure-assigned-to-object-property-directly">Calling closure assigned to object property directly</a> and <a href="https://stackoverflow.com/questions/6775774/anonymous-function-for-a-method-of-an-object">Anonymous function for a method of an object</a> describe calling it directly, not within the object.  Thank you</p>
  
  <pre><code>class myClass
  {
      public function go()
      {
          $this-&gt;scope;
      }
  }
  
  $myObj=new myClass();
  $myObj-&gt;scope=function()
  {
      echo('Print This!');
  };
  $myObj-&gt;go();
  </code></pre>