我尝试通过使用以下内容将"="符号编码为其等效的html:
htmlentities("This is my test and it = this");
结果是:
<p>This is my test and it = this</p>1
注意到等号是如何不编码的吗?我知道有一个HTML等效项。我可以使用什么替代函数对此字符串进行编码?
谢谢。
我知道有一个等效的 HTML
等号不是为 HTML 编码的,没有理由这样做。
您可能正在考虑URL编码,这将是%3d
:
urlencode("This is my test and it = this");
// => "This+is+my+test+and+it+%3D+this"
不需要对
=
进行编码;它是HTML安全的。不过,如果你真的想:=
echo str_replace('=', '=', htmlentities("This is my test and it = this"));
演示