fork download
  1. <?php
  2.  
  3. $a = 1;
  4. $b = 2;
  5. $x = function ($n) use (&$a, $b) {
  6. echo "a=$a, b=$b, n=$n\n";
  7. };
  8.  
  9. $x(10); // a=1,b=2,n=10
  10. $a = 3;
  11. $b = 3;
  12. $x(5); // a=3, b=2, n=5
Success #stdin #stdout 0.01s 24400KB
stdin
Standard input is empty
stdout
a=1, b=2, n=10
a=3, b=2, n=5