codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php // classes and there objects can be iterated with the help of foreach // simple iteration class iteratorSample { public $var1 = 'value 1'; public $var2 = 'value 2'; public $var3 = 'value 3'; protected $protected = 'I am protected'; private $private = 'I am private'; function __construct() { foreach($this as $element) { echo $element."\n"; } echo "\n**************\n"; } } $obj = new iteratorSample(); foreach($obj as $element) { echo $element."\n"; } ?>
Private
[
?
]
Run code