CodeIgniter - Which function to use for URL's
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'
精彩评论