title: PHP Parse error: syntax error, unexpected T_PUBLIC
body: <p>I am getting this error in this PHP code on line 3, what could be wrong? This code has been taken from php manual <a href="http://www.php.net/manual/en/language.types.boolean.php#103757" rel="noreferrer">user notes by frank at interactinet dot com</a></p>
  
  <pre><code>&lt;?php
  
  public function myMethod()
  {
  return 'test';
  }
  
  public function myOtherMethod()
  {
  return null;
  }
  
  if($val = $this-&gt;myMethod())
  {
   // $val might be 1 instead of the expected 'test'
  }
  
  if( ($val = $this-&gt;myMethod()) )
  {
  // now $val should be 'test'
  }
  
  // or to check for false
  if( !($val = $this-&gt;myMethod()) )
  {
  // this will not run since $val = 'test' and equates to true
  }
  
  // this is an easy way to assign default value only if a value is not returned:
  
  if( !($val = $this-&gt;myOtherMethod()) )
  {
  $val = 'default'
  }
  
  ?&gt; 
  </code></pre>