~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to tests/classes/array_access_006.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
ZE2 ArrayAccess and ASSIGN_OP operators (+=)
 
3
--FILE--
 
4
<?php 
 
5
 
 
6
class OverloadedArray implements ArrayAccess {
 
7
        public $realArray;
 
8
        
 
9
        function __construct() {
 
10
                $this->realArray = array(1,2,3);
 
11
        }
 
12
 
 
13
        function offsetExists($index) {
 
14
                return array_key_exists($this->realArray, $index);
 
15
        }
 
16
 
 
17
        function offsetGet($index) {
 
18
                return $this->realArray[$index];
 
19
        }
 
20
 
 
21
        function offsetSet($index, $value) {
 
22
                $this->realArray[$index] = $value;
 
23
        }
 
24
 
 
25
        function offsetUnset($index) {
 
26
                unset($this->realArray[$index]);
 
27
        }
 
28
}
 
29
 
 
30
$a = new OverloadedArray;
 
31
$a[1] += 10;
 
32
var_dump($a[1]);
 
33
echo "---Done---\n";
 
34
?>
 
35
--EXPECT--
 
36
int(12)
 
37
---Done---