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