The php program consists of 5 parts, namely: 1. The start tag ""; 2. The delimiter of the PHP statement ";"; 3. Comments include single-line comments "//" and multi-line comments "/*...*/"; 4. Line breaks, which can enhance the readability of the code; 5. Code segments (such as functions, etc.).
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
PHP Components of the program
1. Starting and ending tags, all PHP code must be written inside this pair of tags
// 起始标签 <?php // 结束标签 ?>
2.";": The semicolon is the delimiter of PHP statements and also represents the instruction for code execution
$name = 'PHP中文网'; echo $name;
3. Comment: '//' is a single-line comment '/*...*/' is a multi-line comment
// 这是单行注释 /* 这是 多行 注释 */ # 也可用作注释但不推荐
4. Appropriately add newline indentation between statements to enhance the readability of the code
// 可读性较差 $name = 'PHP中文网';echo $name; // 适当加上换行可读性会更好 $name = 'PHP中文网'; echo $name;
5. Code segment (such as function...)
function sum(int $a, int $b){ // return意思是返回结果给调用者 return ($a+$b); } // 执行,在客户端打印结果并输出 echo sum(10,20);
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of The php program consists of several parts. For more information, please follow other related articles on the PHP Chinese website!