diff options
author | Dmitry Stogov <dmitry@php.net> | 2008-07-08 07:05:04 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2008-07-08 07:05:04 +0000 |
commit | 8d2e0a7e0f91c5906550d81249569cfd822c9598 (patch) | |
tree | 03e99b82c037bcb6b505501d6348959cc1ca1572 /Zend/tests/closure_003.phpt | |
parent | 79807096b5fb0df8cdb3ef517bd0a034f9781d61 (diff) | |
download | php-git-8d2e0a7e0f91c5906550d81249569cfd822c9598.tar.gz |
Added closures support
Diffstat (limited to 'Zend/tests/closure_003.phpt')
-rw-r--r-- | Zend/tests/closure_003.phpt | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Zend/tests/closure_003.phpt b/Zend/tests/closure_003.phpt new file mode 100644 index 0000000000..b191f35e9c --- /dev/null +++ b/Zend/tests/closure_003.phpt @@ -0,0 +1,37 @@ +--TEST-- +Closure 003: Lambda with lexical variables (local scope) +--SKIPIF-- +<?php + if (!class_exists('Closure')) die('skip Closure support is needed'); +?> +--FILE-- +<?php + +function run () { + $x = 4; + + $lambda1 = function () use ($x) { + echo "$x\n"; + }; + + $lambda2 = function () use (&$x) { + echo "$x\n"; + }; + + $lambda1(); + $lambda2(); + $x++; + $lambda1(); + $lambda2(); +} + +run(); + +echo "Done\n"; +?> +--EXPECT-- +4 +4 +4 +5 +Done |