2013-03-17 83 views
0

我使用zend框架及其paginator來獲取頁面中的數組。每件事情都很好,但我對paginator的工作方式有疑問。 首先這是我的代碼示例: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我讓我的陣! 它是如何工作的? PHP中有沒有像__tostring()這樣的函數來完成這些轉換?

回答