织梦模板内加入PHP代码

方法一:模板页面内嵌入PHP

 
 
{dede:name runphp='yes'} $str = "hello"; @me = $str; @me .= "world"; {/dede:name}

最终输出结果为 hello world

方法二:引用PHP文件

 
 
{dede:include runphp='yes' source='value' file='/path/to/your/php/file.php'}
  • PHP文件编写规范:
    • 不需要再加符号;
    • 处理当前标记的值使用 @me
    • 引入PHP并获取运行后的值使用 $DedeMeValue
posted @ 2024-11-22 18:30  黄文Rex  阅读(19)  评论(0)    收藏  举报