I\'ve learn a while ago on StackOverflow that we can get the \"instance ID\" of any resource, for instance:
var_dump(intval(curl_init())); // int(2) var_dum
Have a look at spl_object_hash(). Usage example:
$id = spl_object_hash($object);
Note that you'll need PHP 5 >= 5.2.0 for that to work.