I have the following code:
DEFINE('DEFINEDTESTVAR', 'Hello World');
function callit($callVar) {
echo "The call is ".$callVar;
}
$passthis = 'DEFINEDTESTVAR';
callit($passthis);
I know I can do callit(DEFINEDTESTVAR) but that’s not what I am looking to do. Is it possible?
Either pass the constant itself:
Or access it through
constant()which allows you to test for null in case it isn’t defined (for undefined constants, passing the constant literally results in a string with the constant name):