Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Call to undefined function base_url() in C:\wamp\www\Test-CI\application\views\layout.php on line 5

Hello I am new to CodeIgniter and PHP, I am trying to setup it for the firs time, but it give the following error.

Fatal error: Call to undefined function base_url() in

  1. C:\wamp\www\Test-CI\application\views\layout.php on line 5
     

  2. {main}( ) IN ..\index.php:0 require_once('C:\wamp\www\Test-CI\system\core\CodeIgniter.php' ) IN ..\index.php:202

  3. call_user_func_array ( ) IN ..\CodeIgniter.php:359

  4. Home->index( ) IN ..\CodeIgniter.php:0

  5. CI_Loader->view( ) IN ..\home.php:17

  6. CI_Loader->_ci_load( ) IN ..\Loader.php:419

  7. include('C:\wamp\www\Test-CI\application\views\layout.php' ) IN ..\Loader.php:833

My code :

 <html>     <head>         <meta http-equiv="Content-type" content="text/html; charset=utf-8">         <title>Galleriffic | Custom layout with external controls</title>         <link rel="stylesheet" href="<?php base_url(); ?>/assets/css/basic.css" type="text/css" />         <link rel="stylesheet" href="<?php base_url(); ?>/assets/css/galleriffic-5.css" type="text/css" />                  <!-- <link rel="stylesheet" href="<?php base_url(); ?>/assets/css/white.css" type="text/css" /> -->         <link rel="stylesheet" href="<?php base_url(); ?>/assets/css/black.css" type="text/css" />                  <script type="text/javascript" src="<?php base_url(); ?>/assets/js/jquery-1.3.2.js"></script>         <script type="text/javascript" src="<?php base_url(); ?>/assets/js/jquery.history.js"></script>         <script type="text/javascript" src="<?php base_url(); ?>/assets/js/jquery.galleriffic.js"></script>         <script type="text/javascript" src="<?php base_url(); ?>/assets/js/jquery.opacityrollover.js"></script>         <!-- We only want the thunbnails to display when javascript is disabled -->         <script type="text/javascript">             document.write('<style>.noscript { display: none; }</style>');         </script>     </head> 
like image 551
user1541058 Avatar asked Jul 20 '12 14:07

user1541058


People also ask

What is Base_url () in CodeIgniter?

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.

What is URL Helper in CodeIgniter?

CodeIgniter's URL helpers are groups of utility functions which will help you to call ,create and maintain url. It mainly have more than 20 helpers some of them you might be familiar with are URL, email, form etc. These are some common helper functions that generaly used in web based application for email, files, URLs.


1 Answers

You have to load the url helper to access that function. Either you add

$this->load->helper('url'); 

somewhere in your controller.

Alternately, to have it be loaded automatically everywhere, make sure the line in application/config/autoload.php that looks like

$autoload['helper'] = array('url'); 

has 'url' in that array (as shown above).

like image 73
complex857 Avatar answered Sep 20 '22 00:09

complex857