Scope Rooms · Level 5 of 7

use (&$x) carries a link

One closure captures $count by reference, another by value.

<?php$count = 0;$inc = function () use (&$count) {    $count++;};$inc();$inc();echo 'count ', $count, PHP_EOL;$copy = function () use ($count) {    $count++;    return $count;};echo 'inside ', $copy(), PHP_EOL;echo 'count ', $count, PHP_EOL;

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…
  3. 3…