I am using a third party PHP module which returns a php resource:
resource(1, ABCResult)
While the manual describes how to use the returned object, I am not sure how to actually access the object?
Code is something like this:
$resource = get_new_resource_based_on('this-information');
var_Dump($resource)
outputs:
resource(1, ABCResult)
The manual states as follows:
The method checks username and password of the account holder.
The method returns an instance of ABCResult class.
Methods of returned ABCResult class instances: success it returns true if there is a user with the username and password, otherwise – false
An error text if there is no user for username/password pair.
It returns ID if the user was found with same username and password
I would blame this on the poor documentation. It seems from the documentation that it could be something like this:
$resource = get_new_resource_based_on('this-information');
if ($resource->success()) {
echo 'User ID = '.$resource->ID;
} else {
echo 'Error: '.$resource->error;
}
A resource is an opaque blob which has no inherent meaning. It typically represents something from an external resource which an external library allocated; meaning for example if you're editing an image with the gd library, the gd library allocates the memory somewhere to hold that image. That external resource is not "in PHP", it's not a class or object. But your code still needs some way to refer to that external resource; that's what a resource is.
The resource is only useful to the extension/function which allocated it. To "access" or "do" anything with it you need to use functions which can work with it. And that is entirely specific to what that resource is and what you're supposed to do with it.