mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
@- Added is_callable() function that can be used to find out whether
@ its argument is a valid callable construct. (Andrei)
This commit is contained in:
parent
5258141db8
commit
8112d1beba
2 changed files with 32 additions and 0 deletions
|
@ -336,6 +336,7 @@ function_entry basic_functions[] = {
|
|||
PHP_FE(is_array, first_arg_allow_ref)
|
||||
PHP_FE(is_object, first_arg_allow_ref)
|
||||
PHP_FE(is_scalar, NULL)
|
||||
PHP_FE(is_callable, third_argument_force_ref)
|
||||
|
||||
PHP_FE(error_log, NULL)
|
||||
PHP_FE(call_user_func, NULL)
|
||||
|
@ -2628,6 +2629,36 @@ PHP_FUNCTION(parse_ini_file)
|
|||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ proto bool is_callable(mixed var [, bool syntax_only [, string callable_name ]]) */
|
||||
PHP_FUNCTION(is_callable)
|
||||
{
|
||||
zval **var, **syntax_only, **callable_name;
|
||||
char *name;
|
||||
zend_bool retval;
|
||||
zend_bool syntax = 0;
|
||||
|
||||
if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 3 ||
|
||||
zend_get_parameters_ex(ZEND_NUM_ARGS(), &var, &syntax_only, &callable_name) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
}
|
||||
|
||||
if (ZEND_NUM_ARGS() > 1) {
|
||||
convert_to_boolean_ex(syntax_only);
|
||||
syntax = Z_BVAL_PP(syntax_only);
|
||||
}
|
||||
|
||||
if (ZEND_NUM_ARGS() > 2) {
|
||||
retval = zend_is_callable(*var, syntax, &name);
|
||||
zval_dtor(*callable_name);
|
||||
ZVAL_STRING(*callable_name, name, 0);
|
||||
} else
|
||||
retval = zend_is_callable(*var, syntax, NULL);
|
||||
|
||||
RETURN_BOOL(retval);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
|
|
|
@ -77,6 +77,7 @@ PHP_FUNCTION(is_string);
|
|||
PHP_FUNCTION(is_array);
|
||||
PHP_FUNCTION(is_object);
|
||||
PHP_FUNCTION(is_scalar);
|
||||
PHP_FUNCTION(is_callable);
|
||||
|
||||
PHP_FUNCTION(error_log);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue