在使用CI框架的使用经常碰到跳转和路径方面的问题,site_url()和base_url()很容易混淆,下面来说说他们的区别!
假如你config文件里面的base_url和index_page是这样定义的:
config['base_url'] = "http://domain.com/";
config['index_page'] = "index.php";
那么你若使用site_url("news/php/2");则实际url为
http://domain.com/index.php/news/php/2
若使用base_url("news/php/2");则url为:
http://domain.com/news/php2
发现没有,base_url()少了一个index.php
使用CI框架时,跳转和路径问题常出现,site_url()和base_url()易混淆。通过示例说明,若config文件中base_url为'http://domain.com/',index_page为'index.php',使用site_url('news/php/2')和base_url('news/php/2')得到的实际URL不同,base_url()少了index.php。
1456

被折叠的 条评论
为什么被折叠?



