I don't find any way online or scratching through the PHP docs to do this.
Is there a friendly or light way check if a variable is a Magic Constant like __FILE__ or __DIR__? Similar to is_callable()?
I want to check against the $var passed and run some if/else conditions on it.
Small example.
function test($var) {
if ($var == 'string_value') {
// Do this...
}
elseif (is_magic_constant($var)) {
// Do this...
}
else {
// Do this...
}
}
test('string_value');
test(__FILE__);
Aucun commentaire:
Enregistrer un commentaire