There is no doubt that the answers of kumar_v and nidheesh are absolutely correct. However, I would like to add when to use base_url () and site_url (). Basically, you can use site_url () when creating links for controllers, while base_url () can be used where we need to create URLs for resources such as loading a css or js file or some image.
I always prefer to use site_url () to create links to controllers or ajax urls and base_url () to load assets.
Abhishek
source share