A-A+

【CI框架】site_url()和base_url()的区别

2015年01月02日 CodeIgniter, PHP 暂无评论 阅读 2,198 views 次

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

 

注意:这两个函数在system/helpers/url_helper.php 文件中定义,这个文件属于系统的函数库文件

标签:

给我留言

Copyright © 严佳冬 保留所有权利.   Theme  Ality 百度地图 苏ICP备19045515号-2

用户登录

分享到: