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

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

青灯夜游
Release: 2019-11-28 17:29:04
forward
3121 people have browsed it

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}
Copy after login

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;
?>
Copy after login

Doesn’t it look similar? Take another look and have an if else condition. I won’t write the judgment

[field:global runphp=&#39;yes&#39; name=autoindex] 
$a="<SPAN class=&#39;num active&#39;>"; 
$b="</SPAN>"; 
$c="<(www.jb51.net)SPAN class=&#39;num&#39;>"; 
if (@me > 3) @me = $c.@me.$b; 
else @me = $a.@me.$b; 
[/field:global]
Copy after login

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(&#39;select id,typename from dede_arctype where id=2&#39;);
print_r($row);
{/dede:php}
Copy after login

The output content is:

Array
(
[id] => 2
[typename] => 问答
)
Copy after login

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!

Related labels:
source:word666.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template