class MailAuthGen{
var $mail='test@mail.com';
var $findUid = "SELECT uid from 'accounts' where email='$mail'";
function abc() {
echo $this->findUid;
}
}
when I load this page, the page shows
Parse error: syntax error, unexpected '"'
Even
$findUid = "SELECT uid from 'accounts' where email='".$mail."'";
didn't work.
But, when I didn't use 'class', it executed well.
What's the problem?
The error is with this line. You can't evaluate any variables when declaring properties.
var $findUid = "SELECT uid from 'accounts' where email='$mail'";
// You can't do this ------^
A common workaround is something like:
var $findUid = "SELECT uid from 'accounts' where email='%s'";
Where you can interpolate the value later.