我正在使用 zend 框架及其分页器将数组放入页面。一切都很好,但我对分页器的工作方式有疑问。首先这是我的代码示例:
$arr=array(
'parviz','neda','yazdgerd','hooshang'
);
$paginator =new Zend_Paginator(new Zend_Paginator_Adapter_Array($arr));
$paginator->setItemCountPerPage(5);
$paginator->setCurrentPageNumber(1);
var_dump($paginator);
foreach ($paginator as $key => $value)
{
echo $key .'='.$value;
}
当我使用 var_dump 函数时,它显示如下:
object(Zend_Paginator)[43]
protected '_cacheEnabled' => boolean true
protected '_adapter' =>
object(Zend_Paginator_Adapter_Array)[44]
protected '_array' =>
array
0 => string 'parviz' (length=5)
1 => string 'neda' (length=3)
2 => string 'yazdgerd' (length=5)
3 => string 'hooshang' (length=6)
protected '_count' => int 6
protected '_currentItemCount' => null
protected '_currentItems' => null
protected '_currentPageNumber' => int 1
protected '_filter' => null
protected '_itemCountPerPage' => int 5
protected '_pageCount' => int 2
protected '_pageRange' => null
protected '_pages' => null
protected '_view' => null
当我使用时,Foreach
我得到了我的数组!它是如何工作的?有没有像__tostring()
PHP 那样进行这些转换的函数?