Php 替换' 和类似的html代码及其对应的字符?
所以我有一个字符串是这样的:Php 替换' 和类似的html代码及其对应的字符?,php,Php,所以我有一个字符串是这样的: $string = "This is a test string. It has characters like these: '"; 是否有一个php函数将它们转换为对应的字符,在我的示例中,所需的输出将是: print $string // OUTPUT: This is a test string. It has characters like these: ' 是的,有: htmlspecialchars\u解码($string,ENT\
$string = "This is a test string. It has characters like these: '";
是否有一个php函数将它们转换为对应的字符,在我的示例中,所需的输出将是:
print $string
// OUTPUT: This is a test string. It has characters like these: '
是的,有:
htmlspecialchars\u解码($string,ENT\u引号)代码>
不确定具体的'
char,据我所知,htmlspecialchars
(带entu引号
flag)将撇号(')转换为&039代码>(带前导零)
因此,'代码>值得检查
编辑:
我做了测试,它确实有效:)您可以使用
这就像是一种相反的关系。如果在输入字符串中使用引号,则必须将html\u entity\u decode()
的第二个参数设置为ENT\u quotes
在操作中查看:因此函数也必须删除t
?@Musa Oops,很抱歉,这是一个错误。