1

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?

Community
  • 1
  • 1
user2294256
  • 1,029
  • 1
  • 13
  • 22

1 Answers1

4

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);

Maxim Khan-Magomedov
  • 1,326
  • 12
  • 15