2

jsonコードを出力してエンコードしようとしています...奇妙な結果が得られます..

ここに私のphpコードとヘッダーがあるので、アプリケーションで読むと、htmlではなくjsonコンテンツタイプとして表示されます

header('Content-Type: application/json');
echo "{\"data\":".json_encode($showArray) . "}";

出力は次のとおりです。

{"data":[{"id":"4628","name":"NCIS","season":"11"},{"id":"21934","name":"NCIS: Los Angeles","season":"5"},{"id":"24591","name":"The Real NCIS","season":"1"},{"id":"34498","name":"NCIS: Red","season":"1"},{"id":"38017","name":"NCIS: New Orleans","season":"1"},{"id":"3039","name":"Charmed","season":"8"},{"id":"6125","name":"The Real World","season":"28"},{"id":"32724","name":"Da Vinci's Demons","season":"2"},{"id":"27924","name":"The Franchise","season":"2"},{"id":"6218","name":"The Streets of San Francisco","season":"5"},{"id":"3253","name":"Da Vinci's Inquest","season":"7"},{"id":"6862","name":"Da Vinci's City Hall","season":"1"},{"id":"32034","name":"Oddities: San Francisco","season":"2"},{"id":"14884","name":"San Francisco International Airport","season":"1"},{"id":"2616","name":"Animal Cops: San Francisco","season":"1"},{"id":"5208","name":"Sir Francis Drake","season":"1"},{"id":"29590","name":"Easy Chinese","season":"2"},{"id":"5583","name":"The Arlene Francis Show","season":"1"},{"id":"26665","name":"Jancis Robinson's Wine Course","season":"1"},{"id":"17968","name":"Foul Play","season":"1"}]}
<!-- Hosting24 Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->

ヘッダーを作成しないと、hostin24 分析コードがありません

Hosting24 分析コードが表示される理由を知っている人はいますか? これはそれを追加するサーバーですか?

もしそうなら..誰も無料のPHPサーバーをお勧めしますか?

ありがとう...

4

1 に答える 1

1

ホストが設定した自動追加のように見えます。exit;PHPスクリプトの最後に配置して、自動追加が発生する最後に到達しないようにすることができます。

同様の問題については、こちらを参照してください: Webhoster は、私のコードを壊す JavaScript を挿入します。

編集:ホストが許可するアクセスのレベルに応じて、他のオプション(ハッキーではない)が利用できる場合があることに注意してください。上記のリンクを読んでください。

于 2013-10-09T03:21:16.180 に答える