PHP 8.5.0 Beta 1 available for testing

Voting

: nine minus three?
(Example: nine)

The Note You're Voting On

mohammad alzoqaily
7 years ago
// 1) you can store the name of constant in default variable
// and use it without identify it's name :)

$str= "constName";

define("constName","this is constant");

echo constant($str);


output:
this is constant

// 2) good for dynamic generating constants


function generateConst( $const , $value , $sensitivity=TRUE )
{

define( "$const" , "$value ",$sensitivity);
}

$CONST="cost";
$VALUE="100$";

generateConst( $CONST , $VALUE);

echo constant($const);

output:
100$

<< Back to user notes page

To Top