开发者

CodeIgniter - Which function to use for URL's

开发者 https://www.devze.com 2023-02-15 10:57 出处:网络
Im building my first application using CodeIgniter, i need a bit of advice. There are 2 functions that do the same thing and i was wondering which is the best to use.

Im building my first application using CodeIgniter, i need a bit of advice.

There are 2 functions that do the same thing and i was wondering which is the best to use.

Ok, so usually when im building a site, i link to the homepage by a simple / but if building on a directory, it will take back to the root public_html directory, with codeigniter i have found both

site_url()

and

base_url()

but, they both seem to do t开发者_JAVA百科he same thing .. Just wondering if theres any difference, which one is better to use, etc etc.

Cheers,


If you are using index.php

 site_url()

will include the index.php , and

 base_url()

will not include it.

If you are creating a url to pass, use

 site_url('images/img.png')

otherwise...

 base_url().'images/img.png' 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号