How I can destroy an const? I tried unset( KEY ), but not work.
<?php
define('KEY', 'value');
echo KEY; //output value
unset( KEY ); //no work
?>
How I can destroy an const? I tried unset( KEY ), but not work.
<?php
define('KEY', 'value');
echo KEY; //output value
unset( KEY ); //no work
?>
The closest you can get to unsetting a constant is use of the RunKit extension. See http://php.net/manual/en/function.runkit-constant-remove.php
You can't destroy a constant or alter its value during run time.
Your best option is to use a variable.
$key = "value";
echo $key;
unset($key);
Not to mention; If you could, it would be extremely bad practice :P
This isn't possible. If you could unset a constant then it wouldn't be very constant!
If you really need to delete this constant you probably need to use a variable.
You can't destroy or unset a Constant in PHP and it's value can't change along de Script.