简体   繁体   English

php:为什么不剥离

[英]php: why   is not stripped

Why   为什么  is not stripped in strip_tags() ? strip_tags()没有被剥离? Other than str_replace() any other possibilities? 除了str_replace()还有其他任何可能吗?

Well, it's not a tag :) 好吧,这不是一个标签:)

Also, yeah, html_entity_decode is the way to go. 另外,是的, html_entity_decode是要走的路。

Unlike HTML tags, entities (such as < or   ) represent actual characters. 与HTML标记不同,实体(例如<  )表示实际字符。
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. 如果从一段HTML中删除所有实体,您将终止剥离所有<字符,以及作为实体包含的任何其他字符。

You need to decode the entities into the characters that they represent, using the html_entity_decode function. 您需要使用html_entity_decode函数将实体解码为它们所代表的html_entity_decode

strip_tags() will not remove html entities strip_tags()不会删除html实体

Not sure what you are trying to achieve, but would html_entity_decode() work for you? 不确定你想要实现什么,但html_entity_decode()会为你工作吗? It will turn & nbsp ; 它会变成&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 你可以使用html_entity_decode

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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