Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 替换' 和类似的html代码及其对应的字符?_Php - Fatal编程技术网

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,很抱歉,这是一个错误。