Dedecms using the PHP statement guide _php instance

Source: Internet
Author: User
In Dedecms, the use of the PHP statement itself is the {dede:php} tag can be used, the simplest input such as

Copy the Code code as follows:
{dede:php}

$numA = 1;

$numB = 2;

echo $numA + $numB;

{/dede:php}

From the above statement can be seen dede:php tag can literally make the same use in PHP, the above statement in PHP written as follows

Copy the Code code as follows:
<?
$numA = 1;
$numB = 2;
echo $numA + $numB;
?>

Does it look like it, and then look at another if else condition to judge

Copy the Code code as follows:
[Field:global runphp= ' yes ' name=autoindex]
$a = "";
$b = "";
$c = "< (www.php.net) SPAN class= ' num ' >";
if (@me > 3) @me = $c. @me. $b;
else @me = $a. @me. $b;
[/field:global]

This is written in PHP, I will not write, the following we want to see Dede PHP tags combined with SQL tags.

Output single content with SQL query

Copy the 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 the Code code as follows:
Array
(
[id] = 2
[TypeName] = Q
)

is not very simple ah, have to learn a friend can refer to this article ha.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.