Use of double quotes in a 'input type=“text”' value wont work, string stops at double-quote !

后端 未结 4 1192
一生所求
一生所求 2021-02-04 19:14

How can I make it possible for users to use the \'\"\' (double quote) inside a textfield...

Whenever I do use double-quote in the field (the value) then when receiving t

4条回答
  •  不思量自难忘°
    2021-02-04 19:38

    You have to use htmlspecialchars($str, ENT_QUOTES) or htmlentities($str, ENT_QUOTES) to convert the quotes to the HTML entity ". Those function also take care of other characters that should be encoded.

    mysql_real_escape_string() is only meant for escaping single quotes in database queries, so that you can correctly enter strings with single quotes into your database (and avoid SQL injections).

    EDIT: Added parameters. Thanks to micahwittman

提交回复
热议问题