cvs: php4 /ext/standard basic_functions.c basic_functions.h

From: Date: Wed, 09 May 2001 20:06:39 +0000
Subject: cvs: php4 /ext/standard basic_functions.c basic_functions.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-5632@lists.php.net to get a copy of this message
andrei Wed May 9 13:06:39 2001 EDT Modified files: /php4/ext/standard basic_functions.c basic_functions.h Log: @- Added is_callable() function that can be used to find out whether @ its argument is a valid callable construct. (Andrei) Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.330 php4/ext/standard/basic_functions.c:1.331 --- php4/ext/standard/basic_functions.c:1.330 Sun May 6 12:20:25 2001 +++ php4/ext/standard/basic_functions.c Wed May 9 13:06:39 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.330 2001/05/06 19:20:25 jmoore Exp $ */ +/* $Id: basic_functions.c,v 1.331 2001/05/09 20:06:39 andrei Exp $ */ #include "php.h" #include "php_main.h" @@ -336,6 +336,7 @@ 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) @@ -2624,6 +2625,36 @@ fh.filename = Z_STRVAL_PP(filename); array_init(return_value); zend_parse_ini_file(&fh, 0, ini_parser_cb, return_value); +} +/* }}} */ + + +/* {{{ 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); } /* }}} */ Index: php4/ext/standard/basic_functions.h diff -u php4/ext/standard/basic_functions.h:1.75 php4/ext/standard/basic_functions.h:1.76 --- php4/ext/standard/basic_functions.h:1.75 Sat Mar 3 17:17:21 2001 +++ php4/ext/standard/basic_functions.h Wed May 9 13:06:39 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.h,v 1.75 2001/03/04 01:17:21 zeev Exp $ */ +/* $Id: basic_functions.h,v 1.76 2001/05/09 20:06:39 andrei Exp $ */ #ifndef BASIC_FUNCTIONS_H #define BASIC_FUNCTIONS_H @@ -77,6 +77,7 @@ PHP_FUNCTION(is_array); PHP_FUNCTION(is_object); PHP_FUNCTION(is_scalar); +PHP_FUNCTION(is_callable); PHP_FUNCTION(error_log);

« previous php.cvs (#5632) next »