title: PHP. Possible to use variable for object?
body: <p>-EDIT- Yes this actually does work. I see that now...</p>
  
  <p>Is it possible to use a variable to determine a property?</p>
  
  <p>I have 2 classes that are called as part of my controller</p>
  
  <pre><code>$this-&gt;document-&gt;setPageNum
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$this-&gt;document2-&gt;setPageNum
  </code></pre>
  
  <p>I would like to use something like</p>
  
  <pre><code>if (is_array($pagenum)) {
      $doc = 'document';
  } else {
      $doc = 'document2';
  }
  
  $this-&gt;$doc-&gt;setPageNum = $pagenum;
  </code></pre>
  
  <p>Is that possible to do?</p>