$route['scribed-qb/(:any)/(:any)/(:any)'] funktioniert nicht.
P粉155832941
P粉155832941 2023-07-30 19:03:57
0
1
643
<p>Wenn ich URI-Segment 2 und 3 verwende, funktioniert es, aber wenn ich URI-Segment 4 hinzufüge, funktioniert es nicht. </p><p>Die URL sollte so aussehen... http://localhost/maruf/scribed-qb/bcs/44th-bcs-english/how-has-the-phrase-digital-detox- wurde-in-der-passage-erklärt? </p><p>Aber es wird angezeigt als... http://localhost/maruf/scribed-qb/bcs/how-has-the-phrase-digital-detox-been-explained-in-the - Durchgang? Und beide URLs zeigen 404. </p><p>Hier sind meine Routing-Einstellungen.</p><p><br /></p> <pre class="brush:php;toolbar:false;">$route['geschrieben-qb/(:num)'] = 'geschrieben-qb'; //funktioniert $route['geschrieben-qb/(:any)/(:any)'] = 'geschrieben-qb/geschrieben_qb_details/$1/$2'; //funktioniert $route['scribed-qb/(:any)/(:any)/(:any)'] = 'scribed-qb/scribed_qb_answer/$1/$2/$3'; //funktioniert nicht</pre> <p>Mein Controller ist...</p> <pre class="brush:php;toolbar:false;">public function index(){ $data['qb_list'] = $this->Question_bank_model->get_qb_with_category(FALSE); //Fußzeilendaten $data['main_content'] = 'geschrieben_qb'; $this->load->view('include/template',$data); } // funktioniert gut öffentliche Funktion geschrieben_qb_details($category, $slug = NULL){ $config['uri_segment'] = 2; $slug = $this->uri->segment(3); //Daten $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(empty($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']; //Sicht $data['main_content'] = 'geschrieben_qb_details'; $this->load->view('include/template',$data); } // funktioniert gut öffentliche Funktion geschrieben_qb_answer($slug = NULL, $slug2 = NULL){ $config['uri_segment'] = 2; $slug = $this->uri->segment(3); $slug2 = $this->uri->segment(4); //Daten $data['qb_info'] = $this->Question_bank_model->get_qb_answer_details($slug, $slug2, $config['uri_segment']); if(empty($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']; //Sicht $data['main_content'] = 'answer'; $this->load->view('include/template',$data); }// es funktioniert nicht</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'); return $query->result_array(); } $query = $this->db->get_where('qb_post', array('qb_exam_slug' => $slug)); return $query->row_array(); } öffentliche Funktion get_qb_answer_details($slug2 = FALSE){ if($slug2 === FALSE){ $this->db->where('qb_exam_answer_active',1); $query = $this->db->get('qb_exam_ans'); return $query->result_array(); } $query = $this->db->get_where('qb_exam_ans', array('qb_exam_question_slug' => $slug2)); return $query->row_array(); }</pre> <p> /$3';中,不起作用。它显示404错误。</p>
P粉155832941
P粉155832941

Antworte allen(1)
P粉323224129

您的路由重叠了。

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

请查看文档中的注释:
注释1:
注释2:
注释3:

路由不是过滤器,当您使用(:any)时,它表示任何内容!为什么第一个和第二个有效?因为您首先检查是否为数字,对于第一个未捕获的任何内容都会被第二个捕获,这意味着第三个永远不起作用。这就像是如果...否则...而不是如果...否则如果...否则...

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!