title: Alternative syntax for accessing a class variable in PHP
body: <p>I just stumbled upon an interesting syntax in a PHP script:</p>
  
  <pre><code>echo $foo-&gt;{'bar'};
  </code></pre>
  
  <p>$foo in this case is an object returned from PHP's json_decode() function, but it works well when accessing public members of any object.</p>
  
  <p>I've tried to find out why this syntax was used instead of the more common:</p>
  
  <pre><code>echo $foo-&gt;bar;
  </code></pre>
  
  <p>Does accessing a class member with the syntax from the first example offer anything special, compared to the second example?</p>