Home  >  Article  >  Backend Development  >  CI框架中site_url()和base_url()的区别_php技巧

CI框架中site_url()和base_url()的区别_php技巧

WBOY
WBOYOriginal
2016-05-16 20:25:581221browse

在使用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()的区别了呢,有疑问就请留言吧。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn