Home>Article>CMS Tutorial> How to use php statements in dedecms? (user's guidance)

How to use php statements in dedecms? (user's guidance)

青灯夜游
青灯夜游 forward
2019-11-28 17:29:04 3001browse

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:

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=""; $b=""; $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!

Statement:
This article is reproduced at:word666.com. If there is any infringement, please contact admin@php.cn delete