base_url()

base_url($uri = '', $protocol = NULL)

Parameters:
  • $uri (string) – URI string
  • $protocol (string) – Protocol, e.g. ‘http’ or ‘https’
Returns:

Base URL

Return type:

string

Returns your site base URL, as specified in your config file. Example:

echo base_url();

This function returns the same thing as site_url(), without the index_page or url_suffix being appended.

Also like site_url(), you can supply segments as a string or an array. Here is a string example:

echo base_url("blog/post/123");

The above example would return something like: http://example.com/blog/post/123

This is useful because unlike site_url(), you can supply a string to a file, such as an image or stylesheet. For example:

echo base_url("images/icons/edit.png");

This would give you something like: http://example.com/images/icons/edit.png

This function is an alias for CI_Config::base_url(). For more info, please see the Config Library documentation.

doc_CodeIgniter
2016-10-15 16:30:53
Comments
Leave a Comment

Please login to continue.