title: Passing variable defined as a function, through as a paramter, and calling it in that function - PHP
body: <p>I have the following:</p>
  
  <pre><code>class Delegator
  {
      public $Create;
      public $Update;
      public $Delete;
  }
  
  // Inside controller 1
  
  $delegator = new Delegator();
  $delegator-&gt;Create = function(){ /**/ };
  $delegator-&gt;Update = function(){ /**/ };
  $delegator-&gt;Delete = function(){ /**/ };
  
  InvokeAction( $delegator );
  
  //-------------------
  
  // Inside controller 2
  
  function InvokeAction( Delegator &amp;$delegator )
  {
      switch( $something )
      {
          case "create":
              $delegator-&gt;Create(); // Says Create method is undefined.
          break;
      }
  }
  
  //-------------------
  </code></pre>
  
  <p>In the Invoke action function, it calls the Create variable as if it's a function, but it cannot see it? any ideas what i'm doing wrong?</p>
  
  <p><strong>ANSWER----------------</strong></p>
  
  <pre><code>call_user_func( $delegator-&gt;Create, /* parameters go here if needs be */ );
  </code></pre>