In Dedecms, the use of PHP statements, itself is a {dede:php} tag can be used, the simplest input such as
Copy Code code as follows:
{dede:php}
$numA = 1;
$numB = 2;
echo $numA + $numB;
{/dede:php}
From the above statement you can see that the dede:php tag can be true to the same use in PHP, the above statements in PHP written as follows
Copy Code code as follows:
?
$numA = 1;
$numB = 2;
echo $numA + $numB;
?>
Does it look a lot like ah, and then look at one more if the condition is judged
Copy Code code as follows:
[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]
This is written in PHP I do not write, the following we want to see Dede PHP tags combined with SQL tags used.
Combining SQL query output single content
Copy Code code as follows:
{dede:php}
$row = $dsql->getone (' Select Id,typename from Dede_arctype where id=2 ');
Print_r ($row);
{/dede:php}
The content of this output is
Copy Code code as follows:
Array
(
[ID] => 2
[TypeName] => questions and Answers
)
is not very simple ah, there is a need to learn friends can refer to this article ha.