訪問php頁面報一下錯誤的解決辦法

今天訪問我們老大的php接口,報一下錯誤的解決辦法:

  報錯內容:                    Warning: date(): 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 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /home/tgroupapi/v4/group/functions.php on line 302

Warning: Cannot modify header information - headers already sent by (output started at /home/tgroupapi/v4/group/functions.php:295) in /home/tgroupapi/v4/group/functions.php on line 156
解決辦法

通過搜索,發現從php5.3 ,當對使用date()等函數時,如果timezone設置不正確,在每一次調用時間函數時,都會產生E_NOTICE 或者 E_WARNING 信息。知道了問題的根源,解決的方法有三種,任選一種即可。

一、在頁頭使用date_default_timezone_set()設置 date_default_timezone_set(‘PRC’);
二、在頁頭使用ini_set(‘date.timezone’,'Asia/Shanghai’);
三、修改php.ini。打開php5.ini查找date.timezone 去掉前面的分號修改成爲:date.timezone =PRC

注意:上述設置都是針對中國大陸來設置的,同時PRC也可以用Asia/Shanghai,Asia/Chongqing,Asia/Urumqi來代替。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章