1.2.230. Constant Scalar Expressions¶
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.230.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 - More |
Precision |
Very high |
Features |
constant-scalar-expression |
Available in |