2013-05-17 40 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);