mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Add get_resource_id() function
Behavior is same as for (int) $resource, just under a clearer name. Also type-safe, in that the parameter actually needs to be a resource. Closes GH-5427.
This commit is contained in:
parent
d5d99ce8d1
commit
a0abc26ef7
5 changed files with 44 additions and 0 deletions
|
@ -1495,6 +1495,20 @@ ZEND_FUNCTION(get_resource_type)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto int get_resource_id(resource res)
|
||||
Get the resource ID for a given resource */
|
||||
ZEND_FUNCTION(get_resource_id)
|
||||
{
|
||||
zval *resource;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_START(1, 1)
|
||||
Z_PARAM_RESOURCE(resource)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
RETURN_LONG(Z_RES_HANDLE_P(resource));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array get_resources([string resource_type])
|
||||
Get an array with all active resources */
|
||||
ZEND_FUNCTION(get_resources)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue