site_url()和base_url()之间有什么区别? [英] what is the difference between site_url() and base_url()?
问题描述
正如我在某些资源中读到的,中的
几乎是相同的,虽然我的版本的codeigniter(2.1.3)没有一个site_url()在它的config.php文件(在config目录)。 base_url()
和 site_url()
c> codeigniter
As I have read in some resources, base_url()
and site_url()
functions in codeigniter
are almost the same, although my version of codeigniter (2.1.3) does not have a site_url() in it's config.php file (in config directory).
但是它们之间有什么区别,因为我看到了带有参数的site_url()和从未见过base_url()持有任何?
Yet are there differences between them in any way since I have seen site_url() with parameters and never seen base_url() holding any?
推荐答案
echo base_url(); // http://example.com/website
echo site_url(); // http://example.com/website/index.php
(例如css,js,image),请使用 base_url()
,否则 site_url()
更好。
if you want a URL access to a resource (such as css, js, image), use base_url()
, otherwise, site_url()
is better.
这篇关于site_url()和base_url()之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!