Skip to content

Instantly share code, notes, and snippets.

@shadda
Created May 30, 2014 20:22
Show Gist options
  • Select an option

  • Save shadda/60559ffa8cdeab7ca447 to your computer and use it in GitHub Desktop.

Select an option

Save shadda/60559ffa8cdeab7ca447 to your computer and use it in GitHub Desktop.
<?php
$foo = new stdClass;
$foo->bar = 1;
try
{
$f = function() use($foo)
{
var_dump($foo); //should be 1
$foo->bar++;
var_dump($foo); //should be 2
$foo->bar++;
throw new Exception("boogers");
$foo->bar = 20; // will never get run
};
$f();
}
catch(Exception $e)
{
var_dump('error', $foo); //should be 3
}
var_dump($foo->bar); //should be 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment