xref: /PHP-8.1/Zend/tests/closure_003.phpt (revision f8d79582)
1--TEST--
2Closure 003: Lambda with lexical variables (local scope)
3--FILE--
4<?php
5
6function run () {
7    $x = 4;
8
9    $lambda1 = function () use ($x) {
10        echo "$x\n";
11    };
12
13    $lambda2 = function () use (&$x) {
14        echo "$x\n";
15    };
16
17    $lambda1();
18    $lambda2();
19    $x++;
20    $lambda1();
21    $lambda2();
22}
23
24run();
25
26echo "Done\n";
27?>
28--EXPECT--
294
304
314
325
33Done
34