Destroy a specific key using the definition function

How can I destroy const? I tried disabling (KEY) but did not work.

<?php define('KEY', 'value'); echo KEY; //output value unset( KEY ); //no work ?> 
+4
source share
5 answers

Constants created with define() cannot be undefined after creation.

+8
source

Closest you can disable the constant - use the RunKit extension. See http://php.net/manual/en/function.runkit-constant-remove.php

+3
source

You cannot destroy a constant or change its value at run time.

Your best option is to use a variable.

 $key = "value"; echo $key; unset($key); 

Not to mention; If you could, this would be extremely bad practice: P

0
source

It's impossible. If you could disable the constant, then it will not be very constant!

If you really need to remove this constant, you probably need to use a variable.

0
source

You cannot destroy or disable a constant in PHP, and its value cannot change by the value of Script.

0
source

All Articles