global statement removal: hphp/test [7/x]
[hiphop-php.git] / hphp / test / quick / zend_closure_005.php
blobaabbb17d68afaa0d2a33b65a03ebf4696bd38d58
1 <?php
3 class A {
4 private $x;
6 function __construct($x) {
7 $this->x = $x;
10 function getIncer($val) {
11 return function() use ($val) {
12 $this->x += $val;
16 function getPrinter() {
17 return function() {
18 echo $this->x."\n";
22 function printX() {
23 echo $this->x."\n";
27 $a = new A(3);
28 $incer = $a->getIncer(2);
29 $printer = $a->getPrinter();
31 $a->printX();
32 $printer();
33 $incer();
34 $a->printX();
35 $printer();
37 unset($a);
39 $incer();
40 $printer();
42 unset($incer);
43 $printer();
45 unset($printer);