如何将PHP代码添加到.tpl文件中

abs*_*tek 5 php smarty

我需要从php文件到.tpl文件显示一些外部数据.为此,我想将php文件包含到.tpl文件中.我试过以下代码来显示php文件内容到tpl.

{php} include('custom_code.php'); {/php}
Run Code Online (Sandbox Code Playgroud)

但在页面输出是 include('custom_code.php');

rod*_*ehm 4

{php}已被弃用。查看使用插件扩展 Smarty

\n\n

将以下内容放入\xe2\x80\xa6/plugins/function.yourplugin.php

\n\n
<?php\nfunction smarty_function_yourplugin(array $params, Smarty_Template_Instance) {\n    include \'your_other_file.php\';\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

并在您的模板中使用:

\n\n
{yourplugin}\n
Run Code Online (Sandbox Code Playgroud)\n