This function return base url or url upto root for a project, and it is very useful to add external css files links, to add external java script files, display images from public folder and create links that are in route files.
Set base_url value
- Visit your project
- open app folder
- next open Config folder
- then App.php page
- set base_url value according to your project.
for example we have a project of name blog, so base_url will be.
public $baseURL = 'http://localhost/blog/';
Create link of assets files and images from public folder
First of all make sure, in your project public folder, you have created sub folders
images, js, css to keep external files there.
<link rel="stylesheet" href="<?=base_url('css/main.css')?>" >
Image file link
<img src="<?=base_url('images/flower.jpg')?>" width="200" height="200" />