"; 2. The delimiter of the PHP statement ";"; 3. Comments, with single-line comments "// ", multi-line comments "/*...*/"; 4. Line breaks, which can enhance the readability of the code; 5. Code segments (such as functions, etc.)."/> "; 2. The delimiter of the PHP statement ";"; 3. Comments, with single-line comments "// ", multi-line comments "/*...*/"; 4. Line breaks, which can enhance the readability of the code; 5. Code segments (such as functions, etc.).">

Home >Backend Development >PHP Problem >The php program consists of several parts

The php program consists of several parts

青灯夜游
青灯夜游Original
2021-06-07 12:03:064937browse

The php program consists of 5 parts, namely: 1. The start tag "3f10a6701c0a7442757d539860b3e574"; 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 php program consists of several parts

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 = &#39;PHP中文网&#39;;
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 = &#39;PHP中文网&#39;;
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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn