1.2.227. Constant Dynamic Creation

Registering constant with dynamic values. Dynamic values include values read in external sources (files, databases, remote API, ), random sources (time, rand(), …)

Dynamic constants are not possible with the const keyword, though static constant expression allows for a good range of combinations, including conditions.

<?php

$a = range(0, 4);
foreach($array as $i) {
    define("A$i", $i);
    define("N$i", true);
}

define("C", 5);

?>

See also PHP Constants.

1.2.227.1. Specs

Short name

Constants/DynamicCreation

Rulesets

All, Appinfo, CE, Changed Behavior

Exakat since

1.6.7

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

constant

Available in

Entreprise Edition, Community Edition, Exakat Cloud