PHP语句
PHP教程 - PHP语句
PHP代码块
代码块是被分组为一个单元的语句的列表。
句法
在PHP中,我们使用{}来包装代码块并通知编译器说“这是一组言论"。
例子
下面的代码组将两个打印语句结合在一起并输出A和B,如果天空的颜色是蓝色的。
<?PHP
$sky_color = "blue";
if($sky_color == "blue") {
print("A \n");
print("B \n");
}
print("Here I am from www.w3cschool.cn.");
?>
上面的代码生成以下结果。

实施例2
下面的代码显示了如何创建三个简单语句。
<?php
//an expression statement
2 + 3;
//another expression statement
print("PHP!");
//a control statement
if(3 > 2)
{
//an assignment statement
$a = 3;
}
?>
上面的代码生成以下结果。

PHP评论
在编程中,注释是我们的代码的描述。
标记注释的语法
在PHP中有三种方法来创建注释:
- //
- /* */, and
- #.
笔记2
// 和#表示“忽略此行的其余部分,
<?php
print "This is printed\n";
// print "This is not printed\n";
# print "This is not printed\n";
print "This is printed\n";
?>
上面的代码生成以下结果。

/* means "Ignore everything until you see */."
<?php
print "This is printed\n";
/* print "This is not printed\n";
print "This is not printed\n"; */
?>
上面的代码生成以下结果。