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

The php program consists of several parts

青灯夜游
Release: 2023-03-10 11:36:01
Original
4935 people have browsed it

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 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

// 结束标签
?>
Copy after login

2.";": The semicolon is the delimiter of PHP statements and also represents the instruction for code execution

$name = &#39;PHP中文网&#39;;
echo $name;
Copy after login

3. Comment: '//' is a single-line comment '/*...*/' is a multi-line comment

// 这是单行注释

/*
这是
多行
注释
*/

# 也可用作注释但不推荐
Copy after login

4. Appropriately add newline indentation between statements to enhance the readability of the code

// 可读性较差
$name = 'PHP中文网';echo $name;

// 适当加上换行可读性会更好
$name = &#39;PHP中文网&#39;;
echo $name;
Copy after login

5. Code segment (such as function...)

function sum(int $a, int $b){
    // return意思是返回结果给调用者
    return ($a+$b);
}

// 执行,在客户端打印结果并输出
echo sum(10,20);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template