简体   繁体   中英

PHP htmlentities Double Encoding

I'm trying to save the contents of a WYSIWYG input into an Oracle database. Here's what I'm using:

$data = htmlentities($_POST['data'], ENT_QUOTES, "UTF-8");

My expectation is that when I'm going to put John's as the value for the input, it will be saved on the database as John's , but instead it is being saved as John' .

To me it looks like a double HTML entity encoding issue.

Can you help me fix this?

Browsing through the documentation , I noticed that the last parameter is a boolean for double encoding.

$data = htmlentities($_POST['data'], ENT_QUOTES, "UTF-8", false);

did the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM