克服 PHP、SoapServer、UTF-8 和非英文字符的编码问题?

Overcome Encoding Problems with PHP, SoapServer, UTF-8, and non English Characters?(克服 PHP、SoapServer、UTF-8 和非英文字符的编码问题?)
本文介绍了克服 PHP、SoapServer、UTF-8 和非英文字符的编码问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我在让 PHP 与 SoapServer + UTF-8 配合使用时遇到问题.任何时候任何人发送带有非英语字符(即有趣的引号、重音字符等)的 Soap 请求时,SoapServer 都会抛出一个异常,说错误的请求".我试过用 utf8_decode 解码请求,甚至 HTML 特殊字符对文本进行编码.没有什么对我有用.

I'm having problems getting PHP to play nicely with SoapServer + UTF-8. Anytime anyone sends a Soap Request with non english characters (i.e. funny quotes, accented characters, etc) the SoapServer throws an exception saying "Bad Request." I've tried decoding the request with utf8_decode and even HTML Special Characters encoded the text. Nothing is working for me.

我正在寻找正确方向的点,因为我现在迷路了.

I'm looking for a point in the right direction because I'm lost at the moment.

推荐答案

确保 SoapServer 和 SoapClient 使用 UTF- 初始化8 编码:

make sure both SoapServer and SoapClient are initialized with UTF-8 encoding:

$client = new SoapClient("some.wsdl", array('encoding'=>'UTF-8'));
$server = new SoapServer("some.wsdl", array('encoding'=>'UTF-8'));

使用有趣的引号、重音字符等"处理请求的 XML.验证?

does the XML of the requests with the "funny quotes, accented characters, etc." validate?

这篇关于克服 PHP、SoapServer、UTF-8 和非英文字符的编码问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Subtract time in PHP(在 PHP 中减去时间)
Limit execution time of an function or command PHP(限制函数或命令 PHP 的执行时间)
How to sum N number of time (HH:MM Format)?(如何求和 N 次(HH:MM 格式)?)
How to get current time in milliseconds in PHP?(如何在 PHP 中以毫秒为单位获取当前时间?)
How to check if time is between two times in PHP(如何检查时间是否在 PHP 中的两次之间)
Convert number of minutes into hours amp; minutes using PHP(将分钟数转换为小时数分钟使用 PHP)