我有以下代码
$jsonReplaces = array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"');我得到了运行php4的以下错误消息:
Parse error: syntax error, unexpected '/', expecting ')' 运行php5也不是一种选择。对于如何在php4中实现这一点,有什么想法吗?
发布于 2014-09-09 14:40:55
我认为您在writecodeonline.com中发现了一个bug。我尝试过各种编写和存储类似$jsonReplaces = array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"');的方法,每次尝试都会失败。好像网站不能解析这个。可能是stripslashes()的一些问题(只是猜测)。我在另一个编辑器和PHP 4.4.9的本地测试环境中尝试过相同的代码,一切都很好。
例如,在这里尝试您的代码:
http://sandbox.onlinephpfunctions.com/
发布于 2014-09-09 14:32:55
我没有php4,但是您可以试试这个,不要在数组中转义第一项
$jsonReplaces = array("\", "/", "\n", "\t", "\r", "\b", "\f", '"' );发布于 2014-09-09 14:59:12
你能试试这个吗?
$jsonReplaces = array(html_entity_decode("\"), "/", "\n", "\t", "\r", "\b", "\f", '"');如果tehre是一个\\的问题,也许使用html实体可以做到这一点.
https://stackoverflow.com/questions/25746979
复制相似问题