开发者

PHP Escaping angle brackets for <!--HTML-->?

开发者 https://www.devze.com 2023-03-25 07:47 出处:网络
Having a lot of trouble escaping angle brackets.. $embeds = preg_replace(<!--nextpage-->, \'\', $embeds,开发者_如何学Go 1);

Having a lot of trouble escaping angle brackets..

$embeds = preg_replace(<!--nextpage-->, '', $embeds,开发者_如何学Go 1);

Did find that strip_tags() is suppose to do the trick, but must have messed up somewhere.

What would be the best way to remove the < !--nextpage-->?


Do you want to strip or to escape angel brackets?

Stripping works with strip_tags() if the HTML is valid. Example: $embeds = strip_tags($embeds);

Escaping can be done using html_special_chars(). Example: $embeds = htmlspecialchars($embeds, ENT_NOQUOTES);

You can try the following as well:

preg_replace('/<!--.+-->/U', '', $embeds)
0

精彩评论

暂无评论...
验证码 换一张
取 消