所以我有一个像这样的字符串:
$string = "This is a test string. It has characters like these: '";
Run Code Online (Sandbox Code Playgroud)
是否有一个PHP函数将这些转换为它们的对应字符,在我的例子中,所需的输出将是:
print $string
// OUTPUT: This is a test string. It has characters like these: '
Run Code Online (Sandbox Code Playgroud)
Yar*_* U. 15
就在这里:
htmlspecialchars_decode($string, ENT_QUOTES);
不知道具体的'char,据我所知htmlspecialchars(带ENT_QUOTES标志)将撇号(')转换为'(带前导零)
所以'值得检查 的确切行为
编辑:我做了测试,它确实工作:)
你可以使用html_entity_decode()
这就像反向性.如果在输入字符串中使用引号,则必须将第二个参数设置html_entity_decode()为ENT_QUOTES
看到它的实际效果:http://sandbox.onlinephpfunctions.com/code/7f4649eb47a8e639c514787a100b63bbad4bc8c6