When I try to do this:
var $example = "Example";
echo <<<EOT
<p>$example</p>
EOT;
I get this error:
Parse error: syntax error, unexpected T_VAR in ..... on line ...
What is going on here?? To my knowledge this should work.
I'm using PHP 5.3.5.
The var keyword on the first line is for declaring variables in classes only. Leave it out.
D'oh. Removing the 'var' keyword fixed it. Thanks for the input guys!
Unfortunately however it didn't solve my actual problem. See here:
$param = array_merge($_REQUEST, $_FILES, $_COOKIE);
$param['example'] = "example";
example();
function example()
{
global $param;
echo <<<EOT
<p>$param['example']</p>
EOT;
return;
}
This time the complaint is:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in ..... on line ...
Again, what is going on here?
$param[example]. Or write {$param['example']}.{$param['example']}
var.var? like in Pascal or JavaScript... not in PHP