简体   繁体   English

检查 php 中的内置 function

[英]Check built-in function in php

I want to verify if a string value has the name of a built-in function in php.我想验证一个字符串值是否具有 php 中的内置 function 的名称。 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.我使用了 function_exists function 但我只在非内置函数中使用 call_user_func_array。

Thanks谢谢

You can use get_defined_functions您可以使用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; function function_exists将为内置和用户定义返回 true,使用此代码您只能使用内置函数进行检查;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM