我們會聽過這一種句話,在網絡上不要相信任何輸入信息,我們都必須進行參數過濾,下面我就來介紹過濾分頁參數吧,有需要的朋友可參考,實例代碼如下:
- $this->load->library ( 'pagination' );
- $config ['base_url'] = site_url () . '/guest/show';
- $config ['total_rows'] = $c;
- $config ['per_page'] = $pernum = 15;
- $config ['uri_segment'] = 3;
- $config ['use_page_numbers'] = TRUE;
- $config ['first_link'] = '第一頁';
- $config ['last_link'] = '最后一頁';
- $config ['num_links'] = 5;
- $this->pagination->initialize ( $config );
- if (! $this->uri->segment ( 3 )) {
- $currentnum = 0;
- } else {
- $currentnum = is_numeric($this->uri->segment ( 3 ))?(intval($this->uri->segment ( 3 ) - 1)) * $pernum:0;
- }
- $current_page=is_numeric($this->uri->segment ( 3 ))?intval($this->uri->segment ( 3 )):1;
- if($current_page){
- $data ['title'] = '第'.$current_page.'頁-留言本-大冶實驗高中首屆宏志班網站';
- }//開源代碼Vevb.com
- else{
- $data ['title'] = '留言本-大冶實驗高中首屆宏志班網站';
- }
- $data ['liuyan'] = $this->ly->getLy ( $pernum, $currentnum );
其中有兩句代碼如下:
- $current_page=is_numeric($this->uri->segment ( 3 ))?intval($this->uri->segment ( 3 )):1;
- $currentnum = is_numeric($this->uri->segment ( 3 ))?(intval($this->uri->segment ( 3 ) - 1)) * $pernum;
這兩句判斷了參數是否為數字,防止非法字符輸入.
新聞熱點
疑難解答