Scope Rooms · Level 4 of 7

use packs a copy

A closure captures $price with use, then $price changes outside.

<?php$price = 10;$show = function () use ($price) {    return 'price ' . $price;};$price = 20;echo $show(), PHP_EOL;echo 'now ' . $price, PHP_EOL;

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…