我自己写了一个CMS,它在PHP 5.6版本之前工作得很好。现在,PHP7正在启动,我希望我的内容管理系统做好准备。在这个内容管理系统中,我使用PEAR库,我已经将它升级到版本1.1,因为据说这个版本支持PHP7。
现在我有以下关于HTML_Template_IT包的问题:当我试图加载模板文件和后来的setCurrentBlock('meta-tags')时,我得到消息“无法找到这个块”meta-tags‘“
有没有人有同样的问题,并能解决它?非常感谢你的帮助!
这是我在index.php中的代码:
require_once('HTML/Template/ITX.php');
$tpl = new HTML_Template_ITX(TEMPLATE_DIR);
// Einlesen der Haupttemplate-Datei
$tpl->loadTemplatefile('main_tpl.html', true, true);
// Meta-Tags ausgeben
$tpl->setCurrentBlock('meta-tags');
$tpl->setVariable('author', AUTHOR);
$tpl->setVariable('description', DESCRIPTION);
$tpl->setVariable('keywords', KEYWORDS);
$tpl->setVariable('page_topic', PAGE_TOPIC);
$tpl->setVariable('publisher', PUBLISHER);
$tpl->setVariable('google_verify', GOOGLE_VERIFY);
$tpl->parseCurrentBlock();以下是来自我的模板-文件main_tpl.html的相应详细信息:
<!-- BEGIN meta-tags -->
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="author" content="{author}" />
<meta name="Content-Language" content="de" />
<meta name="description" content="{description}" />
<meta name="keywords" content="{keywords}" />
<meta name="page-topic" content="{page_topic}" />
<meta name="publisher" content="{publisher}" />
<meta name="google-site-verification" content="{google_verify}" />
<meta name="rating" content="general" />
<meta name="revisit-after" content="10 days" />
<meta name="robots" content="index, follow" />
<!-- END meta-tags -->这是浏览器中的输出:
Cannot find this block"meta-tags' 发布于 2017-01-20 14:18:10
让它在PHP7上运行的主要问题是其preg_replace中的e修饰符。您必须将其替换到IT.php中的1091行附近
return preg_replace_callback(
"#<!-- INCLUDE (.*) -->#im",
function ($m) { $this->getFile($m[1]); },
$content
);我的机器上没有安装PEAR,但是现在它可以工作了,因为我注释掉了require 'PEAR.php'。我还更改了构造函数,使用__construct来消除弃用警告,这些警告仍然有效,但将在PHP8中删除。
https://stackoverflow.com/questions/39944630
复制相似问题