string - How to use single quotes within double quotes in PHP? -
creating link in php:
echo "<a href=\"$currentfile?rowid=$row['id']\">click here</a>";
this throws error: parse error: parse error, expecting 't_string' or 't_variable' or 't_num_string'
. how can this?
also, mixing single , double quotes, , escaping double quotes reduces readability , generates errors. there better way create quotes syntax, %q() in ruby?
working php 5.2.8.
the problem array variable interpolation. syntax either
"$row[id]"
or
"{$row['id']}"
so:
"<a href=\"$currentfile?rowid=$row[id]\">click here</a>"
see http://php.net/manual/en/language.types.string.php#language.types.string.parsing.
Comments
Post a Comment