简体   繁体   中英

PHP htmlentities() and htmlspecialchars() are broken / do not work

I have used these two functions in the past,and they worked fine. I'm developing a CakePHP application and for some reason use of either of these functions does NOTHING. I've setup a simple test, and I can't believe it's returning true:

$loc_title = htmlentities($location['locations']['title']);

if(htmlentities($location['locations']['title']) === $location['locations']['title']){

    echo "htmlentaties is broken.";
}

What could cause these functions to stop working properly?

Consider changing

htmlentities($location['locations']['title'] === $location['locations']['title'])

to

htmlentities($location['locations']['title']) === $location['locations']['title']

for instance ;-)

Beause what you're doing here is you escape entities in the result of comparison of title with itself. Which most likely evaluates to true.

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