title: How to assign a member function to an array and call it
body: <p>I'm currently doing it this way, but seems to not be the proper way:</p>
  
  <pre><code>class Name
  {
      protected $jobs2do;
  
      public function __construct($string) {
          $this-&gt;jobs2do[] = $this-&gt;do;
      }
  
          public function do() {
          ...
      }
  }
  </code></pre>
  
  <p>Because directly assign a function will cause warning, should do something like:</p>
  
  <pre><code>function func()
  {
  ...
  }
  
  $func_array[] = 'func';
  </code></pre>
  
  <p>say, put it into a string, but I don't know how to do it when it's a member function.</p>
  
  <p>Is the following version OK?:</p>
  
  <pre><code>class Name
  {
      public $jobs2do;
  
      public function __construct($string) {
          $this-&gt;jobs2do[] = array($this,'do');
      }
  
          public function do() {
          ...
      }
  }
  </code></pre>
  
  <p>when call it, just:</p>
  
  <pre><code>$instance = new Name();
  foreach ($instance-&gt;jobs2do as $job)
  {
      call_user_func($job);
  }
  </code></pre>