2013-05-17 38 views
1

以下是从另一个问题:Handling data in a PHP JSON Object问题与JSON的file_get_contents取

$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"; 
} 

我的问题:什么是这两个之间的区别:我检查file_get_contents() PHP manual

file_get_contents($jsonurl,0,null,null) 
file_get_contents($jsonurl) 

,但仍然不完全了解它,换句话说,如果我使用这条线:

file_get_contents($jsonurl) 

会发生什么?

回答

4

它将使用默认参数(false,null,-1,null)。在你的情况下,你几乎相同(0评估为false,第二个作为没有参数,所以-1)。

所以最好只用file_get_contents($jsonurl);