echo("<input type='hidden' name='myvar' value='". $myvar."'>");
if $myvar has a single quote in it, the text is stop there" I don't get the rest of the string.
of course it will.
cos say if $myvar = "i wouldn't"
then you'll get :
<input type='hidden' name='myvar' value='i wouldn't'>
hence,
value='i wouldn'
the t' part will just lie there in the TAG.
but If you used :
echo('<input type="hidden" name="myvar" value="'. $myvar.'">');
there would be no problem, cos the single quote is enclosed within Double quotes now.
But now, you may wonder what if a double quote comes in between the two double quotes. well, then again It will get cutoff.
so, you should convert that double quote to &quot; using [man]htmlspecialchars[/man]
then it will be something like :
echo('<input type="hidden" name="myvar" value="'. htmlspecialchars($myvar).'">');
🙂