Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with echo base_url

I have already loaded the URL helper, I have set the base url in config, yet this code seems to gave me:

PHP Error was encountered

Severity: Error

Message: Call to undefined function base_url()

Filename: views/site_navigation.php

Line Number: 6

Here is line number six:

<li><a href="<?php echo base_url(); ?>/welcome">Home</a></li> 
like image 863
KGdB Avatar asked Apr 30 '15 00:04

KGdB


People also ask

What is the difference between Site_url and base_url?

Basically one can use site_url() while creating links for controllers whereas base_url() can be used where we need to create urls for the assets like loading a css or js file or some image .

What is base_url ()?

base_url() is the URL of your CodeIgniter root or the location of the index. php file along with a trailing slash appended to the end of the URL. If the domain name is example.com and the website is using HTTPS as well as www. Further, the index.

How do I find the base URL in CI?

The base URL of the site can be configured in application/config/config. php file. It is URL to your CodeIgniter root. Typically, this will be your base URL, with a trailing slash e.g.

How can change base path in CodeIgniter?

$config['base_url'] = "http://".$_SERVER['SERVER_NAME']."/mysite/"; This configuration will work in both localhost and server.


1 Answers

This error means only one thing that you did not load the url helper correctly. Please follow the documentation and load it as specified from your current action or from the constructor of your controller.

like image 100
SaidbakR Avatar answered Sep 22 '22 10:09

SaidbakR