use define () unless you consider readability, class constants, or focus on micro-optimizations
In PHP, it is customary to use the Define () function to define constants. But starting at some point, PHP can also use the const keyword to declare constants. So when you define constants, which way do you use them?
The an
Objective C # Principle 22: Define external interfaces with events
Item 22: Define outgoing interfaces with events
You can use events to define some external interfaces for your type. The event is based on the delegate, because the delegate can provide type-safe function signature to the event handle. In addition, most examples of delegation are described by
Recall: # define usage,
Ansi c stipulates that: # can contain spaces or tabs, and # can contain spaces between the command and other parts. It can appear anywhere and the scope ranges from the definition to the end of the file.
Before preprocessing, the system deletes the combination of backslash and linefeed. Therefore, commands can be extended to several physical rows, which form a single logical row.
// Each #
1. Difference
(1) Definition, execution time, scope
Definition, Execution time:
#define pchar char *
typedef char *pchar;
The definition of the format difference, it is obvious to note that define is not a semicolon (text substitution), and typedef is a comma (type of renaming).
At the same time, the define is processed by the preprocessor, making
How to define PHP_VERSION_ID and php_version_id
PHP_VERSION_ID is an integer that indicates the current PHP version. It is used from php5.2.7, for example, 50207 indicates 5.2.7.Macros related to the PHP version are defined in the phpsrcdir/main/php_version.h file, as follows:
// File Location: phpsrc/main/php_version.h/* automatically generated by configure * // * edit configure. in to change version number */# d
We usually define non-constant values as constants, which are generally represented in all capitals, with no dollar sign in front of them, and can reduce errors in team development. So what's the difference between a define and a const?1, const is a language structure, and define is a function that can be specified by the third argument for case sensitivity. True
About define (' Discuz_root ', substr (DirName (__file__), 0,-7)); Understanding define (' Discuz_root ', substr (DirName (__file__), 0,-7)) ;Get site root directoryFor the above statement has not understood what is meant to check the relevant information a little closedFirst: This statement consists of three functions of define (), substr (), DirName ()1.
For example: Here the program file starts with the following #define statement
Copy Code code as follows:
#define N 10
#define PI 3.14
#define MAX 10000
#define HEIGTH 6.65
...
...
Let's say the program is running an error, and if we have
1. Const is used for class member variable definition, once defined and cannot change its value. Define defines global constants that can be accessed everywhere.2. Define cannot be defined in a class and const can.3. Const cannot define constants in conditional statementsif (... { const FOO = ' BAR '; // if (..... ) {
css|frontpage| Tips
When many people find it convenient to define CSS in DW4, they start complaining that FP2000 can't define CSS, or even criticize how bad FP2000 is. In fact, it's easy to define CSS in FP2000, even in some ways it's easier to define than DW4!
Define styl
Replace const, enum, and inline # define
Basically, you can use const, enum, or inline to replace the pre-processing command # define. There are two main reasons:
# Define ASPECT_RATIO 1.653
1. preprocessing commands are pre-processed before compilation (gcc-E is used for preprocessing, and its output file is used as the input for gcc-S compilation ), therefore,
This article mainly introduces how to use mini-define to implement modular Management of front-end code. It is a very good article. We recommend it to partners who need it.
Mini-define
A simple front-end modular framework based on require. If you don't want to spend time learning require. js or look at the long cmd/amd specifications, then this mini-define is yo
Difference between const and define in php
If (...){
Const FOO = 'bar'; // invalid
}
But
If (...){
Define ('foo', 'bar'); // valid
}
4. const uses a normal constant name, and define can use an expression as the name. For example:
Const FOO = 'bar ';
For ($ I = 0; $ I
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 #define Macro name
As a recommendation and a common practice for a broad range of programmers, macro names often use all uppercase letters.
Advantages of usin
This article introduces, PHP in the Static,const and define usage difference, the need for friends to refer to it.In PHP, often use static,const and define, today we come to understand the difference between the next three what?Define: A macro can be used instead of a constant value, and it can be used instead of an expression or even a code snippet. (Macros are
Yesterday interview by the Group of Examiners asked about the const and define similarities and differences, began to be simple, then asked my head is a group of paste. Almost a summary of the information today1. Const and define.Both can be used to define constants, but the const definition defines the type of the constant, so it is more accurate. #define只是简单的文本
Define the nameset:
A nameset is a multidimensional expression (MDX) that returns a group of dimension members ). You can define a nameset and save it as part of a multi-dimensional dataset definition. You can also apply it on the client.ProgramCreate a nameset. You can create a nameset by combining Multidimensional Dataset data, Arithmetic Operators, numbers, and functions. The name set can be used by the
link address: http://blog.sina.com.cn/s/blog_686188ef0100klku.html
# define is a macro definition Command provided in C, the main purpose is to provide some convenience for Program programmers in programming, and to improve the program running efficiency to a certain extent, however, when learning this command, students often cannot understand the essence of the command. It always creates some confusions and misuse it during programming, This
you want to know thisArticleMore details about the things mentioned in. These things can be used as a reference.
Okay. Where can I start? First, we will configure the plug-in that contains the view and add org. Eclipse. UI. navigator to the dependency (dependencies. Then, we use the org. Eclipse. UI. Views extension point to define a view part and use the org. Eclipse. UI. Navigator. commonnavigator class as the implementation class of the view par
Basically, you can use Const,enum or inline to replace a pre-order # define. The main reasons are two:#define Aspect_ratio 1.6531. Pre-processing instructions are preprocessed prior to compilation (GCC-E is preprocessed, its output file is compiled as Gcc-s input), so the compiler is not able to see the symbol Aspect_ratio defined by # define, so it does not appe
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.