-2

次のエラーが表示されます。

解析エラー: 構文エラー、2 行目の C:\wamp\www\test.php の予期しない T_STRING

Redditのフロントページからキーを印刷しようとしているときに

*$json_string* 解析エラーを修正し、Reddit のフロント ページからキーを表示するにはどうすればよいですか? 前もって感謝します。

test.php

   <?php
        $json_string = "{"kind": "Listing", "data": {"modhash": "", "children": [{"kind": "t3", "data": {"domain": "i.imgur.com", "banned_by": null, "media_embed": {}, "subreddit": "pics", "selftext_html": null, "selftext": "", "likes": null, "link_flair_text": null, "id": "1d7lch", "clicked": false, "title": "Graves of a Catholic woman and her Protestant husband, who were not allowed to be buried together.", ... ";

        $a = json_decode($json_string);
        echo $a.keys();
    ?>
4

3 に答える 3

3

一重引用符で囲むか、二重引用符をエスケープしますか?

于 2013-04-27T13:56:28.743 に答える
2

自分で文字列に入れないでください。これを使用してください。

    $a = json_decode(file_get_contents('http://www.reddit.com/.json'));

それはあなたのためにエスケープを処理します。

于 2013-04-27T14:24:59.980 に答える