在使用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为
立即学习“PHP免费学习笔记(深入)”;
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()的区别了呢,有疑问就请留言吧。
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号