I have some strings in the database like SNEAKERS "SUPER STAR" GOLDEN GOOSE
. These are the titles for some products. When I output it normally inside a <p>
it shows the quotes, but when I echo it inside an input value, <input type="text" value="<?= $product->title ?">
the string gets truncated before the first double quote, so the value becomes just SNEAKERS
.
Is there a way I can output the double quotes inside the value of an input ?
EDIT: The closing tag was a typo, in the code it is closed.
Use htmlspecialchars like so:
htmlspecialchars($product->title);
i.e
<input type="text" value="<?= htmlspecialchars($product->title) ?>">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With