In PHP we can iterate any object by using the list of items,for getting list of items we have foreach loop in php. So that there will only the visible properties is being listed.
We have loops concept for iterating throughout data list in php.
Following is the simple example for object iteration :
class TestClass{
public $public='PublicVal';
protected $protected='ProtectedVal';
private $private='PrivateVal';
function myfunc() {
return 'func';
}
function iterateVisible(){
foreach($this as $key => $value) {
print "$key => $value\n";
}
}
}
$obj=new TestClass();
$obj->iterateVisible();
0 Comment(s)