Value of Do{}while (0) When macro definition (#define) in C languageRecently found in the code of the new company everywhere used do{...} while (0), Google a bit, found that stack overflow early on a lot of discussion, summed up the discussion,
This article provides a detailed analysis of the differences between static, const, and define in php. For more information, see
Define section:Macros can be used not only to replace constant values, but also to replace expressions or even code
Parse the differences between static, const, and define in php. Define: macros can be used not only to replace constant values, but also to replace expressions or even code segments. (Macros have powerful functions but are prone to errors, so their
This article provides a detailed analysis of the differences between const and define in php. For more information, see
This article provides a detailed analysis of the differences between const and define in php. For more information, see
1.
: This article mainly introduces the difference between const and define in php (supplement). If you are interested in PHP tutorials, refer to it. A constant is the identifier (name) of a simple value ). As its name implies, this value cannot be
The pros and cons of Const and # define, thus deriving the meaning of const;Both const and # define have a similar function, which is to define a "constant";This is the way you want to replace a # define constant. This is a way to define macros.
1. Simple define Definition#define MAXTIME 1000A simple maxtime is defined, it represents 1000, if it is written inside the programif (IThe compiler replaces the maxtime with 1000 before processing the code.Such a definition looks similar to a
When defining constants in PHP, you can use both the const and define methods, so what's the difference between them?1.const the definition of a class member variable , once defined, cannot be modified. Define is not available for definition of
When defining constants in PHP, you can use both the const and define methods, so what's the difference between them?1.const the definition of a class member variable, once defined, cannot be modified. Define is not available for definition of class
Define section:Macros can be used not only to replace constant values, but also to replace expressions or even code segments. (Macros have powerful functions but are prone to errors, so their advantages and disadvantages are quite controversial
(1) different compiler processing methodsDefine macros are expanded during the preprocessing phase.Const constants are used during the compile run phase.(2) Different types and security checksDefine macros have no type, do not do any type checking,
Today, we have compiled some # define usage to share with you!1. Simple define Definition#define MAXTIME 1000A simple maxtime is defined, it represents 1000, if it is written inside the programif (IThe compiler replaces the maxtime with 1000 before
Define section:Macros can be used not only to replace constant values, but also to replace expressions or even code segments. (Macros have powerful functions but are prone to errors, so their advantages and disadvantages are quite controversial
Define section:Macros can be used instead of constant values, and can be used instead of expressions, even code snippets. (Macros are powerful, but error-prone, so their pros and cons are quite controversial.) )The syntax for a macro is:Macro value #
Questions about using define in include
a.php
Define (' PATH ', DirName (__file__)); Include ('./index.php '); . . .?>
b.php
Include (.. /a.php); Echo PATH;
Where a.php and index.php are in the same folder, and b.php in A.php's
(1) different compiler processing methodsDefine macros are expanded during the preprocessing phase.Const constants are used during the compile run phase.(2) Different types and security checksDefine macros have no type, do not do any type checking,
Define section:Macros can be used not only in place of constant values, but also in substitution of expressions or even code snippets. (Macros are powerful, but they are also prone to errors, so the pros and cons are quite controversial.) )
The
From: Http://stackoverflow.com/questions/2447791/define-vs-constSame point: Both can define constantsConst foo = ' Bar ';d efind (' foo ', ' Bar ');The disadvantage of const:1.const must be declared in Top-level-scope (top-level domain):For example:
Parse the differences between const and define in php. 1. const is used for defining class member variables. once defined, the value cannot be changed. Define defines global constants that can be accessed anywhere. 2. define cannot be defined in the
Today in C language practice involves the use of TypeDef and define problems, then what is the difference between them? Why use typedef in this case? In which case, why use define?Did you ever think about it when you were studying C?Today I decided
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.