iterators are often used by us to facilitate data management when reading large amounts of data in a database.
fruits[$this->position]; } Returns the current key public function key () { return $this->position } //Move down one element public function next () { + + $this->position; } Move to the first element of public function rewind () { $this->position = 0; } Determine if there is a subsequent element public function valid () { return isset ($this->fruits[$this->position+1]);} }
Enables data in an object to be accessed like an array
container = Array ("One" = 1, "One" = 2, "three" = 3); }//Assign Public function Offsetset ($offset, $value) {if (Is_null ($offset)) {$this->container [] = $value; } else {$this->container[$offset] = $value; }}//A key exists public function offsetexists ($offset) {return isset ($this->container[$offset]); }//Delete key value public function Offsetunset ($offset) {unset ($this->container[$offset]); }//Gets the value corresponding to the public function Offsetget ($offset) {return isset ($this->container[$offset])? $this->cont ainer[$offset]:null; }} $obj = new obj (), Var_dump (Isset ($obj ["" "]), Var_dump ($obj [" ""]), unset ($obj ["]"), Var_dump (Isset ($obj [" "]), $obj [' both '] =" A value "; Var_dump ($obj [' both ']); Echo $obj [' both ']; $obj [] = ' Append 1 '; $obj [] = ' Append 2 '; $obj [] = ' AppE nd 3 '; var_dump ($obj);
Enables an object to count properties
fruits);} } $basket = new Basket (); Echo count ($basket);
The above describes the use of iterator,arrayaccess and countable in the 24php, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.