修复php警告Warning: Use of undefined constant GMT – assumed ‘GMT’ (this will throw an Error in a future version of PHP)

很久以前逍遥乐就使用了张戈的动态,最近逍遥对我的博客网站从环境到主题插件都进行了升级改造。详细可以看我写的《逍遥乐博客全新改版,5年来首次大改,我做了哪些改动》,最近在针对网站SEO做各种优化,其中就包括,检查的时候发现报了错。出现了这个警告提示“ – assumed ‘’ (this will throw an Error in a future version of PHP)”。
修复php警告Warning: Use of undefined constant GMT – assumed ‘GMT’ (this will throw an Error in a future version of PHP)

修复这个php警告
经过检查发现是php7.2更改了常量书写格式导致的错误。解决方法如下:

一、打开的文件,找到的那行代码。

<lastmod><?php $ltime = get_lastpostmodified(GMT);$ltime = gmdate(‘Y-m-d\TH:i:s+00:00’, strtotime($ltime)); echo $ltime; ?></lastmod>

二、将GMT用双引号括起来,保存,上传网站。

<lastmod><?php $ltime = get_lastpostmodified(“GMT”);$ltime = gmdate(‘Y-m-d\TH:i:s+00:00’, strtotime($ltime)); echo $ltime; ?></lastmod>

三、重新打开sitemap就正常了。

修复php警告Warning: Use of undefined constant GMT – assumed ‘GMT’ (this will throw an Error in a future version of PHP)
sitemap错误修复