1.2.1414. Variable Constants

Variable constants are constants whose value is accessed via the function constant(). Otherwise, there is no way to dynamically access a constant (aka, when the developer has the name of the constant as a incoming parameter, and it requires the value of it).

<?php

const A = 'constant_value';

$constant_name = 'A';

$variableConstant = constant($constant_name);

?>

See also constant().

1.2.1414.1. Specs

Short name

Constants/VariableConstant

Rulesets

All, Appinfo, CE, Changed Behavior

Exakat since

0.8.4

PHP Version

All

Severity

Time To Fix

Precision

Very high

Features

dynamic-constant, constant

Available in

Entreprise Edition, Community Edition, Exakat Cloud