title: Set a dynamic property in the class constructor
body: <pre><code>class QuestionVO {
  
  public $qtype;
  
  function __construct() { //echo $this-&gt;qtype; //it's not empty and displays value
      $this-&gt;{$this-&gt;qtype} = true;
  }
  </code></pre>
  
  <p>pdo statement</p>
  
  <pre><code>$statement-&gt;setFetchMode(\PDO::FETCH_CLASS, get_class(new QuestionVO()));
  </code></pre>
  
  <p>it's throwing fatal error.</p>
  
  <p>however, the document says at <a href="http://code.tutsplus.com/tutorials/why-you-should-be-using-phps-pdo-for-database-access--net-12059" rel="nofollow">http://code.tutsplus.com/tutorials/why-you-should-be-using-phps-pdo-for-database-access--net-12059</a> 
  "This fetch method allows you to fetch data directly into a class of your choosing. When you use FETCH_CLASS, the properties of your object are set BEFORE the constructor is called. "</p>
  
  <pre><code>Fatal error&lt;/b&gt;:  Cannot access empty property in QuestionVO
  </code></pre>
  
  <p>for instance if $qtype = truefalse</p>
  
  <p>I need a dynamic property set automatically as truefalse = true for the object.</p>