简体   繁体   中英

php: why   is not stripped

Why   is not stripped in strip_tags() ? Other than str_replace() any other possibilities?

Well, it's not a tag :)

Also, yeah, html_entity_decode is the way to go.

Unlike HTML tags, entities (such as < or   ) represent actual characters.
If you strip all entities from a piece of HTML, you'll ned up stripping all < characters, as well as any other characters that were included as entities.

You need to decode the entities into the characters that they represent, using the html_entity_decode function.

strip_tags() will not remove html entities

Not sure what you are trying to achieve, but would html_entity_decode() work for you? It will turn & nbsp ; into a non-breaking space.

It's not stripped because, according to the documentation it only strips the tags. &nbsp; isn't a tag, it's an entity character code. You could use html_entity_decode

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