[英]special character in PHP SOAP client
I have text values in an XML document created by the PHP SOAP client that includes an ' (that's an apostrophe). 我在PHP SOAP客户端创建的XML文档中有文本值,其中包含'(即单引号)。 I've confirmed that the encoding is ASCII which should be valid UTF-8.
我已经确认编码为ASCII,应该是有效的UTF-8。 I did it like this:
我这样做是这样的:
foreach ($myarrayofstrings as $s){
echo mb_detect_encoding($s);
}
If I remove the apostrophe like this then the server accepts my request. 如果我这样删除撇号,则服务器接受我的请求。
$myarrayofstrings = str_replace("'", "", $myarrayofstrings);
Question: 题:
Is there anything I can do to ensure this works every time without the str_replace? 没有str_replace,我能做些什么来确保每次都能正常工作吗?
For me always work utf8_encode function instead any replace: 对我来说,始终使用utf8_encode函数代替任何替换:
$myarrayofstrings = utf8_encode($myarrayofstrings);
But i think you can use htmlspecialchars
too 但我认为您也可以使用
htmlspecialchars
<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; // <a href='test'>Test</a>
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.