search
Homephp教程php手册PHP 编码规范(14)

PHP 编码规范(14)

Jun 13, 2016 am 10:20 AM
elseif-elsephpandoperateconditionFormatofcodingspecificationstatementconduct

6 if与else语句

if-else语句应该具有如下格式:


if (condition){ /* 进行操作的条件 */
  statements;
}

if (condition) {/*进行操作的条件. */
  statements;
} else {/*进行操作的条件*/
  statements;
}

if (condition) {/*进行操作的条件*/
  statements;
} else if (condition) {/*进行操作的条件 */
  statements;
} else{/*进行操作的条件*/
  statements;
}

注意:if语句总是用"{"和"}"括起来,避免使用如下容易引起错误的格式:


if (condition) //避免这种写法,他忽略了“{}”
  statement;

注释格式也可以像下面的这种方式写

if (condition) {
/*进行操作的条件*/
  statements;
} else {
/*进行操作的条件*/
  statements;
}

只要可以描述清楚各分支之间的关系,在哪里写注释均可


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment