title: php variable variables {}
body: <p>I need to pass a lot of variables to a PHP class from a database and can't figure out the correct syntax.</p>
  
  <p>This is the class's variable format:</p>
  
  <pre><code>$this-&gt;SetX('X','Y',15);
  </code></pre>
  
  <p>I have tried these but none work:</p>
  
  <pre><code>$var = 'SetX';
  $this-&gt;{$var} = array('foo','bar',15);
  $this-&gt;{$var}('foo','bar',15);
  $this-&gt;{$var} = "'foo','bar',15";
  </code></pre>
  
  <p>But none work, can this be done ??</p>
  
  <p>OK, now understand that this is a method, however the method name and it's associated variables are dynamic and stored in a DB and I therefore need to generate these on the fly.</p>