1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
--TEST-- Closure 024: Clone the Closure object --FILE-- <?php $a = 1; $c = function($add) use(&$a) { return $a+$add; }; $cc = clone $c; echo $c(10)."\n"; echo $cc(10)."\n"; $a++; echo $c(10)."\n"; echo $cc(10)."\n"; echo "Done.\n"; ?> --EXPECT-- 11 11 12 12 Done.