File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
tests /
classes /
iterators_004.phpt
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Feb 21 23:48:06 2012 UTC (12 years, 5 months ago) by
misho
Branches:
php,
MAIN
CVS tags:
v5_4_3elwix,
v5_4_29p0,
v5_4_29,
v5_4_20p0,
v5_4_20,
v5_4_17p0,
v5_4_17,
v5_3_10,
HEAD
php
1: --TEST--
2: ZE2 iterators must be implemented
3: --SKIPIF--
4: <?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
5: --FILE--
6: <?php
7:
8: echo "1st try\n";
9:
10: class c1 {}
11:
12: $obj = new c1();
13:
14: foreach($obj as $w) {
15: echo "object:$w\n";
16: }
17:
18: echo "2nd try\n";
19:
20: class c2 {
21:
22: public $max = 3;
23: public $num = 0;
24:
25: function current() {
26: echo __METHOD__ . "\n";
27: return $this->num;
28: }
29: function next() {
30: echo __METHOD__ . "\n";
31: $this->num++;
32: }
33: function valid() {
34: echo __METHOD__ . "\n";
35: return $this->num < $this->max;
36: }
37: function key() {
38: echo __METHOD__ . "\n";
39: switch($this->num) {
40: case 0: return "1st";
41: case 1: return "2nd";
42: case 2: return "3rd";
43: default: return "???";
44: }
45: }
46: }
47:
48: $obj = new c2();
49:
50: foreach($obj as $v => $w) {
51: echo "object:$v=>$w\n";
52: }
53:
54: print "Done\n";
55: ?>
56: --EXPECTF--
57: 1st try
58: 2nd try
59: object:max=>3
60: object:num=>0
61: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>