~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to Zend/tests/closure_009.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
Closure 009: Using static vars inside lambda
 
3
--FILE--
 
4
<?php
 
5
$a = 1;
 
6
$x = function ($x) use ($a) {
 
7
  static $n = 0;
 
8
  $n++;
 
9
  $a = $n.':'.$a;
 
10
  echo $x.':'.$a."\n";
 
11
};
 
12
$y = function ($x) use (&$a) {
 
13
  static $n = 0;
 
14
  $n++;
 
15
  $a = $n.':'.$a;
 
16
  echo $x.':'.$a."\n";
 
17
};
 
18
$x(1);
 
19
$x(2);
 
20
$x(3);
 
21
$y(4);
 
22
$y(5);
 
23
$y(6);
 
24
?>
 
25
--EXPECT--
 
26
1:1:1
 
27
2:2:1
 
28
3:3:1
 
29
4:1:1
 
30
5:2:1:1
 
31
6:3:2:1:1