php发送/回声'?'对于每个require_once

时间:2018-05-09 07:58:32

标签: php json iis special-characters require-once

我的PHP文件向某些GET-Request发送JSON-Result。 问题是,我一直在客户端解析错误。查看结果字符串,我发现每个结果都以几个问号(?)开头。

逐步削减我的脚本我发现结果包含一个?对于每个require,include,require_once或include_once。 奇怪的是?如果我在浏览器中运行请求,则不可见。但是将结果复制到文本编辑器中会变得可见。

我的服务器是带有php 7.1.7的IIS

(简化)代码如下所示:

lookup.php

<?php
  include_once 'common/server.php';
  echo $srv->QueryTable(qry_ItemList);

server.php

<?php
require_once 'constants.php';
require_once 'sql/queryNAV.php';

class JSON_Server
{
    public function QueryTable($SQLTextName)
    {
        $qry_result = /*(do SQL-Query)*/;
        return json_encode($qry_result);
    }
}
$srv = new JSON_RESTServer;

请求看起来像这样:

http://s-mde/itemLookup.php?number=305475

......结果可能是这样的:

?????[{"Typ":"I","No_":"408835","Description":"Ds Scene it? Twilight","debugCounter":96},{"Typ":"L","No_":"100773","Description":"Axe Deo Roll Diverse 50ml Ro","debugCounter":96},{"Typ":"L","No_":"410296","Description":"Axe Duschgel Africa 250ml Fl.","debugCounter":96},{"Typ":"L","No_":"102939","Description":"Axe Duschgel Alaska 250ml Fl.","debugCounter":96},{"Typ":"L","No_":"408835","Description":"Ds Scene it? Twilight","debugCounter":96},{"Typ":"L","No_":"100332","Description":"Rexona Roll On Men Sport 50ml","debugCounter":96}]

1 个答案:

答案 0 :(得分:0)

您的文件编码是什么?从PHP创建对Android应用程序的JSON响应时,我遇到了类似的问题。通过用UTF-8编码双方来解决它,请求和响应。