Skip to content

Instantly share code, notes, and snippets.

@bayleedev
Created October 16, 2012 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bayleedev/3896743 to your computer and use it in GitHub Desktop.
Save bayleedev/3896743 to your computer and use it in GitHub Desktop.
Can change object but can't write over it
<?php
$response = new stdClass();
echo '1): ' . spl_object_hash($response) . PHP_EOL; // 0000000021e89fcd00000000e93b17ba
call_user_func_array(function($response) {
$response = new stdClass();
echo '2): ' . spl_object_hash($response) . PHP_EOL; // 0000000021e89fcf00000000e93b17ba
}, array($response));
echo '3): ' . spl_object_hash($response) . PHP_EOL; // 0000000021e89fcd00000000e93b17ba
call_user_func_array(function($response) {
$response = new stdClass();
echo '4): ' . spl_object_hash($response) . PHP_EOL; // 0000000021e89fcf00000000e93b17ba // hash descoped and reused
}, array(&$response));
echo '5): ' . spl_object_hash($response) . PHP_EOL; // 0000000021e89fcf00000000e93b17ba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment