Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get instance ID with PHP

I'm looking for a way to get the instance ID of a given object / resource with PHP, the same way var_dump() does:

var_dump(curl_init()); // resource #1 of type curl
var_dump(curl_init()); // resource #2 of type curl

How can I get the instance count without calling var_dump()? Is it possible?

like image 611
Alix Axel Avatar asked Dec 09 '22 18:12

Alix Axel


1 Answers

Convert it to an int to get the resource ID:

$resource= curl_init();
var_dump($resource);
var_dump(intval($resource));
like image 51
leepowers Avatar answered Dec 13 '22 21:12

leepowers