Dedecms php statement guide and dedecmsphp statement Guide
In DEDECMS, php statements can be used with the {dede: php} tag. The simplest input is as follows:
Copy codeThe Code is as follows:
{Dede: php}
$ NumA = 1;
$ NumB = 2;
Echo $ numA + $ numB;
{/Dede: php}
From the preceding statement, we can see that the dede: php tag can be used in the same way in php. The above statement is written in php as follows:
Copy codeThe Code is as follows:
<?
$ NumA = 1;
$ NumB = 2;
Echo $ numA + $ numB;
?>
Does it look a lot like it? Let's look at another judgment using the if else condition.
Copy codeThe Code is as follows:
[Field: global runphp = 'yes' name = autoindex]
$ A = "<SPAN class = 'num activity'> ";
$ B = "</SPAN> ";
$ C = "<(www.jb51.net) SPAN class = 'num'> ";
If (@ me> 3) @ me = $ c. @ me. $ B;
Else @ me = $ a. @ me. $ B;
[/Field: global]
I will not write this code in php. Next we should look at the use of SQL labels combined with dede php labels.
Query and output single content in combination with SQL
Copy codeThe Code is as follows:
{Dede: php}
$ Row = $ dsql-> GetOne ('select id, typename from dede_arctype where id = 2 ');
Print_r ($ row );
{/Dede: php}
The output content is
Copy codeThe Code is as follows:
Array
(
[Id] => 2
[Typename] => Q &
)
Isn't it easy? If you need to learn, please refer to this article.