Home >CMS Tutorial >DEDECMS >How to use php statements in dedecms? (user's guidance)
In DEDECMS, if you use the php statement, the {dede:php} tag can be used. The simplest input is:
{dede:php} $numA = 1; $numB = 2; echo $numA + $numB; {/dede:php}
From the above statement It can be seen that the dede:php tag can be used in the same way in PHP. The above statement is written as follows in PHP:
<? $numA=1; $numB=2; echo $numA+$numB; ?>
Doesn’t it look similar? Take another look and have an if else condition. I won’t write the judgment
[field:global runphp='yes' name=autoindex] $a="<SPAN class='num active'>"; $b="</SPAN>"; $c="<(www.jb51.net)SPAN class='num'>"; if (@me > 3) @me = $c.@me.$b; else @me = $a.@me.$b; [/field:global]
How to write this in php. Next we have to look at the use of dede php tags in combination with sql tags.
[Related course learning: dedecms video tutorial]
Combined with SQL query to output a single piece of content
{dede:php} $row = $dsql->GetOne('select id,typename from dede_arctype where id=2'); print_r($row); {/dede:php}
The output content is:
Array ( [id] => 2 [typename] => 问答 )
Isn’t it very simple? Friends who need to learn can refer to this article.
Recommended learning: dedecms usage tutorial
The above is the detailed content of How to use php statements in dedecms? (user's guidance). For more information, please follow other related articles on the PHP Chinese website!