打開
	pub_dedetag.php
	找到
	function AssignSysTag()
	在
	for函數(shù)結束的地方,即是在
	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;
	$runphp = $CTag->GetInnerText();
	}
	$runphp = str_replace(‘@me’,'$DedeMeValue’,$runphp);
	eval($runphp);
	$this->CTags[$i]->IsReplace = TRUE;
	$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編寫的規(guī)范為:
	一、PHP編碼中不需要再加<??>符號;
	二、假如想處理當前標記的值(上面第一種情況),使用 @me 表示當前的值;
	三、假如直接引入PHP并要獲得運行后的值,必須用 $DedeMeValue 表示運行這個PHP后最終返回的值(因此不能用HTML混合的寫法)。
	例如:
	{dede:field runphp=’yes’}
	$aaa=200;
	$DedeMeValue=100;
	$DedeMeValue = $aaa;
新聞熱點
疑難解答
圖片精選