It is possible to fetch the zend resources (zend_fetch_resource) without knowing the type of the fetching resource? If so, how?
Note: I am writing PHP extension.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, you can.
zend_fetch_resourcewon’t work because it receives the the types of resources that are acceptable and fails if the found one is not one of those.Just use
From the resource zval you can extract the id with
Z_RESVAL(zval). The argumenttypewill be filled with the type of the resource found.However, I don’t see much usage for this, except maybe to create a
var_dumpclone. The problem is that once you retrieve an arbitrary resource, what are you going to do with it?… In general, you know nothing about the returned data structure.You can get the name of the resource directly with: