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
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
What is the role of define in addition to defining constants? Can I change the definition of a constant? Why have the APP been defined so many times? The constant value seems to be a path. Shouldn't it be a defined constant?
Define ("APP", "./admin"
A. php & lt ;? Php & nbsp; define (& nbsp; 'path', dirname (_ FILE _); & nbsp; include ('. /index. php '); & nbsp; about the use of define in include
A. php
define( 'PATH',dirname(__FILE__)); include('./index.php'); . . .?>
B. php
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
1 Version differences:Const requires PHP version "5.3.0Define can be compatible with PHP4,PHP5 and other versions2 Definition of location differences:Constants defined by the Const keyword are defined at compile time, so the const keyword definition
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
Define (& #39; GW_MAXFILESIZE & #39;, & #39; 32768*10 & #39;); echoGW_MAXFILESIZE1; why is the output 32768 instead of 327680? Reading less ...... A conjecture is that php does not replace C as it is. type conversion occurs first, and "*" is ignored
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 class, but const can. 3. const cannot define the
In the smarty template, how does one use a constant defined through define?
Method: {$ smarty. const. Constant name you defined}Articles you may be interested in
Extension of the for loop in the smarty Template
The cycle table in the smarty
In C/C ++, we usually use typedef keywords and # define macro-defined commands to write programs. In some cases, using them will achieve the same effect, however, there are substantial differences. One is the keywords of C/C ++ and the other is
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
We know that private members of a class cannot be accessed outside of the class.
For example, there is the following simple class:
class ClxECS{private:int iPrivate;};
So the following function is not compiled:
void ECS_test(){ClxECS
Recently a product debugging found a problem, together to check a small partner's C program.
The problem is not big, but it exposes a little problem. For example: portb=0x23; He means to place the 5th and 2nd digits 1, but can you see the 5th and
To put it simply, # define is simply replaced, while typedef gets an "alias" for the type ".
1. # define is a pre-processing command. It is a simple replacement during compilation and pre-processing. It does not check the correctness or whether the
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 class, But const can.3. const cannot define constants
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
1 , Syntax Statement: Parameter xx = YY;'Define XX YY Usage: Xx'Xx2 , Scope Parameter The file to be declared; 'Define It is valid from the time the compiler reads this instruction to the end of compilation, or 'Undef Command to make it
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 class, But const can. 3. Const cannot define
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.