Reputation: 1333
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.
Upvotes: 0
Views: 365
Reputation: 1333
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?
Upvotes: 0
Reputation: 31685
The var
keyword on the first line is for declaring variables in classes only. Leave it out.
Upvotes: 5
Reputation: 62395
There is no keyword var
in PHP. Not in PHP5 anyway - it's only accepted due to backward compatibility, and is used to define class variables.
Upvotes: 1
Reputation: 26281
remove the word var.
see http://www.php.net/manual/en/language.variables.basics.php
Upvotes: 3