Home > Backend Development > PHP Tutorial > In-depth understanding of PHP kernel reading 1_PHP tutorial

In-depth understanding of PHP kernel reading 1_PHP tutorial

WBOY
Release: 2016-07-12 09:08:17
Original
1020 people have browsed it

In-depth understanding of php kernel reading 1

Explanation of use of do{ }while(0)
The purpose of writing do{ }while(0) is mainly for the robustness and versatility of the basic functions of the program, and for the flexible use of some codes.
The do{ }while(0) writing method will cause the internal code to execute once and then exit. If this writing method is not used, it will cause compilation errors for programmers who do not follow {} immediately after the if statement, and for those who There is no impact on programming habits using {}.
Example:
#define SAFE_DELETE(p) do{ delete p; p = NULL} while(0) //1. Use do{ }while(0) writing method
#define SAFE_DELETE(p) { delete p; p = NULL} //2. Use {} writing
#define SAFE_DELETE(p) delete p; p = NULL //3. Use nothing
if(NULL != p) SAFE_DELETE(p) //1. No problem 2. No problem 3. There is a problem, there are 2 statements before else, compilation failed
else ...do sth...
if(NULL != p) SAFE_DELETE(p); //1. No problem 2. There is a problem, followed by brackets; Compilation failed 3. There is a problem, there are 2 items before else else ...do sth.. .                                                                                                       // Statement, compilation failed
if(NULL != p) {SAFE_DELETE(p)} //1. No problem 2. No problem 3. No problem
else ...do sth...

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1056012.htmlTechArticleIn-depth understanding of php kernel reading 1 Explanation of the use of do{ }while(0) do{ }while(0) writing The purpose is mainly for the robustness and versatility of the basic functions of the program and the flexible use of some codes. ...
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