[英]URI segment as parameter to function: passing commas,+,date formats as URI segments allowed?
[英]How to add uri segment as parameter into a function?
我将尝试说明我要做什么:
我想要我的网址像:
www.mysite.com/abc-university
/def-university
/fde-university
“大学”之前是大学的名称。 我所有的部分(1)都以大学结尾。
我有一堂课叫做University
。 有get_university()
函数。
在routes.php中,我写道:
$route['(:any)'] = "university/get_university";
这是我班的样子:
class University extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('university_model');
}
function get_university($university_segment){
$query = $this->university_model->get_from_university($university_segment);
$row = $query->row();
echo "Welcome to " . $row->university_name . "page";
}
}
$university_segment
是“ / abc_university。
我想将segment-1(abc_university) get_university($university_segment)
函数作为参数,并根据该大学从数据库中获取信息。
我什至尝试了_remap()
函数,但没有。 谢谢...
function get_university(){
$university_segment=$this->uri->segment(1);
$query = $this->university_model->get_from_university($university_segment);
$row = $query->row();
echo "Welcome to " . $row->university_name . "page";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.