在使用CI框架的使用经常碰到跳转和路径方面的问题,site_url和base_url很容易混淆,下面我们来说说他们的区别:
//在"application/config/config.php"文件中设置:
$config['base_url']='http://localhost/CodeIgniter/'
site_url("student/index/str/1");
base_url("student/index/str/1");
同为一个例子,对site_url与base_url下url的解析如下:
base_url:http://localhost/Codeigniter/student/index/str/1
site_url:http://localhost/Codeigniter/index.php/student/index/str/1
注:你会发现site_url对路径的解析时多了一个index.php