sitemap.php文件报错“Warning: Use of undefined constant GMT - assumed 'GMT' (this will throw an Error in a future version of PHP) ”¶
原文链接: https://www.itylq.com/php-warning-undefined-gmt.html
发布日期: 2022-10-05 迁移时间: 2026-03-21
偶尔查看了下网站sitemap.xml文件记录,发现有一行报错信息 Warning: Use of undefined constant GMT – assumed ‘GMT’ (this will throw an Error in a future version of PHP)。sitemap.xml是由网站后台sitemap.php文件定时更新的,问题的缘由应该在.php文件。

后台打开sitemap.php文件,根据报错信息的关键字“GMT”和代码行号定位到代码位置:

GMT作为常量,在低版本PHP版本中可以直接输入;在高版本PHP中,必须添加” “,否则PHP无法识别。所以,只要给GMT字符串添加上英文双引号就解决了。
本文由WordPress迁移至MkDocs