do { $key = uniqid("is_ref_", true);
} while($key === $var1);
$tmp = $var1; //WE NEED A COPY HERE!!! $var1 = $key; //Set var1 to the value of $key (copy) $same = $var1 === $var2; //Check if $var2 was modified too ... $var1 = $tmp; //Undo our changes ... }
return $same;
}
?>
Although this implementation is quite complete, it can't handle function references and some other minor stuff ATM.
This function is especially useful if you want to serialize a recursive array by hand.
The usage is something like: <?php
$a = 5; $b = 5; var_dump(is_ref($a, $b)); //false