如何在DedeCms 標記中運行PHP,織夢教程
導讀:織夢教程織夢教程打開pub_dedetag.php找到function AssignSysTag()在for函數結束的地方,即是在CODE: 這個地方}////把分析模板輸出到織夢后臺模板。
打開 pub_dedetag.php 找到 function AssignSysTag() 在 for函數結束的地方,即是在 CODE: 這個地方 } // //把分析模板輸出到一個字符串中,并返回 // function GetResult() [Copy to clipboard] —————————– 改為如下代碼 ——————————— CODE: //運行PHP接口 if( $CTag->GetAtt("runphp") == "yes" ) { $DedeMeValue = ""; if($CTag->GetAtt("source")==’value’) { $runphp = $this->CTags[$i]->TagValue; } else{ $DedeMeValue = $this->CTags[$i]->TagValue; $runphdede下瓻模板下載p = $CTag->GetInnerText(); } $runphp = str_replace(‘@me’,’$DedeMeValue’,$runphp); eval($runphp); $this->CTags[$i]->IsReplace = TR織夢模板下載UE; $this->CTags[$i]->TagValue = $DedeMeValue; } } // //把分析模板輸出到一個字符串中,并返回 // function GetResult() [Copy to clipboard] //////////////////////////////////////////// 這樣只要在dedecms的標記中加上 runphp=’yes’ 就可以運行PHP語句了
(用@me表示當前標記的值,$DedeMeValue表示最終返回值,里面為純PHP代碼,不能用<? ?>與THML混合)
PHP代碼放置方式一: {dede:name runphp=’yes’} 這里寫PHP代碼 {/dede:name}
方式二: 假如你想在include的文件中使用PHP,則加上 source=’value’ {dede:include runphp=’yes’ source=’value’ file=”/}
PHP編寫的規范為: 一、PHP編碼中不需要再加<??>符號; 二、假如想處理當前標記的dede免費校板下戰值(上面第一種情況),使用 @me 表示當前的值; 三、假如直接引入PHP并要獲得運行后的值,必須用 $DedeMeValue 表示運行這個PHP后最終返回的值(因此不能用HTML混合的寫法)。
例如: {dede:field runphp=’yes’} $aaa=200; $DedeMeValue=100; $DedeMeValue = $aaa;
相關織夢后臺模板。聲明: 本文由我的SEOUC技術文章主頁發布于:2023-07-22 ,文章如何在DedeCms 標記中運行PHP,織夢教程主要講述標記,標簽,織夢網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_33892.html