Search code examples
phpfunctionnativebuilt-in

Check built-in function in php


I want to verify if a string value has the name of a built-in function in php. There is some way of know it?

I've used function_exists function but I only to use call_user_func_array in non buit-in functions.

Thanks


Solution

  • You can use get_defined_functions

    <?php
    
    $b = get_defined_functions();
    in_array('something', $b['internal']); //FALSE
    in_array('in_array', $b['internal']); //TRUE
    

    The function function_exists will return true for both built-in and user-defined, with this code you can check only with built-in functions;