代碼重現:PHP時區錯誤,而使用錯誤記錄
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('error_log', 'log/log');
ini_set('html_errors', 0);
// trigger an error
echo $test;
如果log/log
是可寫的,你沒有設置date.timezone
在php.ini
或使用date_default_timezone_set
,你會看到這樣的錯誤:
Warning: main(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '1.0/no DST' instead in C:\srv\www\test.php on line 10
Notice: Undefined variable: test in C:\srv\www\test.php on line 10
這是非常翔實的。我的情況是10行是echo $test;
。 PHP沒有告訴任何有關設置錯誤記錄器的內容。
您可以在大型項目上花費大量時間指出這一點。
如果log/log
不可寫,您將只能看到未定義的變量通知。
我認爲PHP可以使用日誌的系統時區設置(這會很明顯)。
Ist是一個錯誤,應該向PHP團隊報告嗎?順便說一句。我使用PHP 5.3.8(不是上次快照)
在你的「代碼重現」$ test從未設置。複製並粘貼錯誤? – FakeRainBrigand
它會觸發一個錯誤,所以php會嘗試記錄它。 – Buddy
好吧,我現在明白了。澄清一下,你在這裏有什麼問題?它看起來像一個錯誤報告。 – FakeRainBrigand