Get Instance ID of an Object in PHP

前端 未结 10 1676
说谎
说谎 2020-12-14 07:19

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         


        
10条回答
  •  一向
    一向 (楼主)
    2020-12-14 07:48

    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.

提交回复
热议问题