$route['written-qb/(:any)/(:any)/(:any)'] tidak berfungsi.
P粉155832941
P粉155832941 2023-07-30 19:03:57
0
1
642
<p>Apabila saya menggunakan uri segmen 2 dan 3, ia berfungsi, tetapi apabila saya menambah uri segmen 4, ia tidak berfungsi. </p><p>URL sepatutnya kelihatan seperti ini... http://localhost/maruf/written-qb/bcs/44th-bcs-english/how-has-the-phrase-digital-detox- telah- diterangkan-dalam-petikan? </p><p>Tetapi ia muncul sebagai... http://localhost/maruf/written-qb/bcs/how-the-phrase-digital-detox-been-explained-in-the - Laluan? Dan kedua-dua URL menunjukkan 404. </p><p>Berikut ialah tetapan penghalaan saya.</p><p><br /></p> <pre class="brush:php;toolbar:false;">$route['written-qb/(:num)'] = 'written-qb'; //berfungsi $route['written-qb/(:any)/(:any)'] = 'written-qb/written_qb_details/$1/$2'; //berfungsi $route['written-qb/(:any)/(:any)/(:any)'] = 'written-qb/written_qb_answer/$1/$2/$3'; //tidak berfungsi</pra> <p>Pengawal saya ialah...</p> <pre class="brush:php;toolbar:false;">indeks fungsi awam(){ $data['qb_list'] = $this->Question_bank_model->get_qb_with_category(FALSE); //data pengaki $data['main_content'] = 'written_qb'; $this->load->view('include/template',$data); } // berfungsi dengan baik fungsi awam written_qb_details($category, $slug = NULL){ $config['uri_segment'] = 2; $slug = $ini->uri->segmen(3); //data $data['qb_list'] = $this->Question_bank_model->get_qb_with_category(FALSE); $data['qb_info'] = $this->Question_bank_model->get_qb_details($slug, $config['uri_segment']); if(kosong($data['qb_info'])){ show_404(); } $data['url_slug'] = $data['qb_info']['qb_exam_slug']; $data['meta_title'] = $data['qb_info']['qb_exam']; $data['meta_description'] = $data['qb_info']['qb_exam_post_meta']; $data['meta_keywords'] = $data['qb_info']['qb_exam_post_tags']; //pandangan $data['main_content'] = 'written_qb_details'; $this->load->view('include/template',$data); } // berfungsi dengan baik fungsi awam written_qb_answer($slug = NULL, $slug2 = NULL){ $config['uri_segment'] = 2; $slug = $ini->uri->segmen(3); $slug2 = $ini->uri->segmen(4); //data $data['qb_info'] = $this->Question_bank_model->dapatkan_qb_answer_details($slug, $slug2, $config['uri_segment']); if(kosong($data['qb_info'])){ show_404(); } $data['url_slug'] = $data['qb_info']['qb_exam_question_slug']; $data['meta_title'] = $data['qb_info']['qb_exam_question']; $data['meta_description'] = $data['qb_info']['qb_exam_answer_meta']; $data['meta_keywords'] = $data['qb_info']['qb_exam_answer_tags']; //pandangan $data['main_content'] = 'jawapan'; $this->load->view('include/template',$data); }// ia tidak berfungsi</pre> <p>而我的模型是...</p> <pre class="brush:php;toolbar:false;">public function get_qb_details($slug = FALSE){ if($slug === FALSE){ $this->db->order_by('qb_post.qb_exam_slug', 'DESC'); $this->db->join('qb_category', 'qb_category.qb_category_name_slug = qb_post.qb_category_name_slug'); $this->db->where('qb_exam_active',1); $query = $this->db->get('qb_post'); kembalikan $query->result_array(); } $query = $this->db->get_where('qb_post', array('qb_exam_slug' => $slug)); kembalikan $query->row_array(); } fungsi awam get_qb_answer_details($slug2 = FALSE){ if($slug2 === SALAH){ $this->db->where('qb_exam_answer_active',1); $query = $this->db->get('qb_exam_ans'); kembalikan $query->result_array(); } $query = $this->db->get_where('qb_exam_ans', array('qb_exam_question_slug' => $slug2)); kembalikan $query->row_array(); }</pre> <p>在控制器"written_qb_answer"中,以及在路由$route['written-qb/(:any)/(:any)/(:any)'] = 'written-qb/written_qb_2/$1/$2 /$3';中,不起作用。它显示404错误。</p>
P粉155832941
P粉155832941

membalas semua(1)
P粉323224129

Laluan anda bertindih.

$route['written-qb/(:num)'] = 'written-qb';  //works
$route['written-qb/(:any)/(:any)'] = 'written-qb/written_qb_details//';  //works
$route['written-qb/(:any)/(:any)/(:any)'] = 'written-qb/written_qb_answer///';  //does not work

Sila lihat ulasan dalam dokumentasi:
Nota 1:
Nota 2:
Nota 3:

Laluan bukan penapis, apabila anda menggunakan (: mana-mana) ia bermakna apa-apa! Mengapa yang pertama dan kedua berfungsi? Kerana anda menyemak nombor dahulu, apa-apa yang tidak ditangkap oleh yang pertama akan ditangkap oleh yang kedua, yang bermaksud yang ketiga tidak akan berfungsi. Macam kalau...lain...bukan kalau...lain kalau...lain...

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!