The following is from another question: Handling data in a PHP JSON Object :
$jsonurl = "http://search.twitter.com/trends.json";
$json = file_get_contents($jsonurl, 0, null, null);
$json_output = json_decode($json);
foreach ($json_output->trends as $trend)
{
echo "{$trend->name}\n";
}
My Question: What is the difference between those two:
file_get_contents($jsonurl,0,null,null)
file_get_contents($jsonurl)
I checked file_get_contents()
PHP manual , but still do not totally understand it, in another words, if i use this line:
file_get_contents($jsonurl)
What will happen?
It will use default parameters ( false
, null
, -1
, null
). In your case you do almost the same ( 0
evaluates as false
, the second null
as no parameter, so -1
).
So better use just file_get_contents($jsonurl);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.