title: Convert value of object into PHP variable (smarty)
body: <p>I am trying to the the value of a HTML tag to a PHP variable. The code I have below will not work, the value of {mytag} is 21.</p>
  
  <p>I have  {mytag} as an HTML hook inside the smarty template to extract a field from a db, so I have to have {mytag}.</p>
  
  <p>The plan is to use the int from the db inside some maths but as {mytag} is treated as an object I have to get the value into another variable.</p>
  
  <pre><code>$t = new stdClass;
  $t-&gt;bat = "{mytag}";
  $bar = $t-&gt;foo;
  ob_start();
  $b = var_export($bar, true);
  echo $b;
  $stdClass = ob_get_contents();
  ob_end_clean();
  $the_var = $stdClass;
  </code></pre>
  
  <p>When I check the output I get the name but not the value. </p>
  
  <pre><code>echo $the_var[0] 
  //prints ' and not 2
  echo $the_var[1] 
  //prints { and not 1
  </code></pre>
  
  <p>How can I get $the_var to contain value 21?</p>