phpfunctionvariableslanguage-construct

Can I use variable functions with language constructs?


This question here kinda address the issue. In my case I would like to call a function like empty() or is_int(). For example:

<?php

    $foo = 'empty';
    $test = NULL;
    $foo($test);

This question is not a duplicate of:

How to call PHP function from string stored in a Variable

My question addresses a native PHP function not a user made function.


Solution

  • Variable function doesn't work with language constructs as you can read in the manual:

    Variable functions won't work with language constructs such as echo, print, unset(), isset(), empty(), include, require and the like. Utilize wrapper functions to make use of any of these constructs as variable functions.