dedecms {dede:php}標籤用法介紹

來源:互聯網
上載者:User


最簡單的輸入如

 代碼如下 複製代碼

{dede:php}

  $numA = 1;

  $numB = 2;

  echo $numA + $numB;

{/dede:php}

從上面語句可以看出dede:php標籤可以名符其實的讓在php中一樣的用法,上面語句在php寫法如下

 代碼如下 複製代碼

<?
$numA=1;
$numB=2;
echo $numA+$numB;
?>


是不是看上去很像啊,再看一個再有if else 條件判斷的

 代碼如下 複製代碼

[field:global runphp='yes' name=autoindex]
$a="<SPAN class='num active'>";
$b="</SPAN>";
$c="<SPAN class='num'>";
 if (@me > 3) @me = $c.@me.$b;
 else @me = $a.@me.$b;
[/field:global]

這個在php中寫法我就不寫了,下面我們要看dede php標籤結合起來sql標籤使用。


結合SQL查詢輸出單條內容

 代碼如下 複製代碼
{dede:php}
$row = $dsql->GetOne('select id,typename from dede_arctype where id=2');
print_r($row);
{/dede:php}
這個輸出的內容是
Array
(
[id] => 2
[typename] => 問答
)

是不是很簡單啊,有需要學習的朋友可以參考一下本文章哈。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.