I have always been confused that .e,g in php i have sql statement
$qry = "select * from table where id = $id";
now can i insert “$” directly inside the quotes or i have to use
$qry = "select * from table where id =".$id." ";
or
$qry = 'select * from table where id = $id';
or
$qry = 'select * from table where id = '$id'';
Which is correct
If the string is in double quotes, variables will be evaluated. If it’s in single quotes, it’s literal and you’ll get exactly what you type.
Here is the relevant manual section for a full explanation:
http://php.net/manual/en/language.types.string.php#language.types.string.parsing
To put actual quotes into the string, you’ll need to alternate them or escape them.
Also, what he said.