Input field containing double quotes value

Use htmlentities:

<input value="<?php echo htmlentities($value);?>">

I suppose your "text box" is an HTML <input> element?

If so, you are displaying it using something like this:

echo '<input name="..." value="' . $yourValue . '" />';

If it's the case, you need to escape the HTML that's contained in your variable, with htmlspecialchars:

echo '<input name="..." value="' . htmlspecialchars($yourValue) . '" />';

Note that you might have to add a couple of parameters, especially to specify the encoding your are using.


This way, considering $yourValue has been initialized like this :

$yourValue = '5 " inches';

You'll get from this generated HTML:

<input name="..." value="5 " inches" />

To that one, which works much better:

<input name="..." value="5 &quot; inches" />

Tags:

Html

Php