Skip to content

Instantly share code, notes, and snippets.

@morfie
Created November 6, 2015 10:44
Show Gist options
  • Save morfie/87a54c1a31db79dae186 to your computer and use it in GitHub Desktop.
Save morfie/87a54c1a31db79dae186 to your computer and use it in GitHub Desktop.
<?php
$test = new \stdClass;
$clone1 = clone $test;
$clone2 = clone $test;
$clone1_0 = clone $clone1;
echo 'TEST hash'.spl_object_hash($test) . PHP_EOL;
echo 'CLONE1 hash'.spl_object_hash($clone1) . PHP_EOL;
echo 'CLONE2 hash'.spl_object_hash($clone2) . PHP_EOL;
$clone1_0_hash = spl_object_hash($clone1_0);
echo 'CLONE1_0 hash'.$clone1_0_hash . PHP_EOL;
unset($clone1_0);
$clone1_1 = clone $clone1;
$clone1_2 = clone $clone1;
echo 'CLONE1_1 hash'.spl_object_hash($clone1_1) . PHP_EOL;
echo 'CLONE1_1 hash'.spl_object_hash($clone1_2) . PHP_EOL;
var_dump( spl_object_hash($clone1_1) == $clone1_0_hash );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment