1.2.1359. Use const¶
The const keyword may be used to define constant, just like the define() function.
When defining a constant, it is recommended to use ‘const’ when the features of the constant are not dynamical (name or value are known at compile time).
This way, constant will be defined at compile time, and not at execution time.
define() function is useful when the constant is not known at compile time, or when case sensitivity is necessary.
<?php
//Do
const A = 1;
// Don't
define('A', 1);
?>
See also Syntax.
1.2.1359.1. Connex PHP features¶
1.2.1359.1.1. Suggestions¶
Use const instead of define()
1.2.1359.1.2. Specs¶
Short name |
Constants/ConstRecommended |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Slow (1 hour) |
Precision |
Very high |
Examples |
|
Available in |