php json returning bool(false)

前端 未结 3 1140
谎友^
谎友^ 2020-12-22 01:15

Any thoughts as to why the following is not working.

$request_url = \"someurl?myId=$id\"; //returns feed like above

$json = file_get_contents($request_url,          


        
3条回答
  •  萌比男神i
    2020-12-22 01:49

    I replicated your problem and I observe bool(false) when the ajax url is wrong (not found). Make sure your "someurl" is valid.

    If the JSON is invalid, your script would still print it correctly. If the url returns nothing you's still observe 'string(0) ""'

    The issue is the invalid url.

提交回复
热议问题