- substr: documentation ( source)
- ob_get_clean: documentation ( source)
- ob_start: documentation ( source)
- strpos: documentation ( source)
- debug_zval_dump: documentation ( source)
- spl_object_hash: documentation ( source)
- hexdec: documentation ( source)
<?php
$a = (object) array();
$b = (object) array();
function object_handle($obj)
{
static $mask = null;
if (null === $mask) {
$o = (object) array();
$h = hexdec(substr(spl_object_hash($o), 0, 16));
ob_start();
debug_zval_dump($o);
$mask = ob_get_clean();
$mask = $h ^ (int) substr($mask, 1 + strpos($mask, '#'));
}
return hexdec(substr(spl_object_hash($obj), 0, 16)) ^ $mask;
}
echo object_handle((object) array()), "\n";
echo object_handle($b), "\n";
echo object_handle($a), "\n";