single and double quotes do not work while converting to input value because of single and double quotes, we need just convert a string to htmlspecialchars before echo.
1 2 3 4 5 6 7 8 9 |
<? $string='"ABC'; ?> <input type="text" value="<?php echo htmlspecialchars($string); ?>" > |
a
If you want to assign value from javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<? $string='"ABC'; ?> <input type="text" id="name" value="" > <script> function htmlDecode(input){ var e = document.createElement('div'); e.innerHTML = input; return e.childNodes[0].nodeValue; } $("#name").val(htmlDecode("<?php echo htmlspecialchars($string); ?>")); </script> |
More Stories
CPU & Memory usage in PHP
Install PHP mcrypt extension on Ubuntu
Text to speech