1.2.236. Constant Scalar Expressions¶
Define constant with the result of static expressions. This means that constants may be defined with the const keyword, with the help of various operators but without any functioncalls.
This feature was introduced in PHP 5.6. It also supports array(), and expressions in arrays.
Those expressions (using simple operators) may only manipulate other constants, and all values must be known at compile time.
<?php
// simple definition
const A = 1;
// constant scalar expression
const B = A * 3;
// constant scalar expression
const C = [A ** 3, '3' => B];
?>
See also Constant Scalar Expressions.
1.2.236.1. Connex PHP features¶
1.2.236.1.1. Specs¶
Short name |
Structures/ConstantScalarExpression |
Rulesets |
All, Appinfo, CE, Changed Behavior, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55 |
Exakat since |
0.8.4 |
PHP Version |
With PHP 5.6 and more recent |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Changed Behavior |
PHP 5.6 |
Precision |
Very high |
Available in |