Kamis, 18 Mei 2017

Codeigniter Call to undefined function base_url()

Problem


An uncaught Exception was encountered
Type: Error
Message: Call to undefined function base_url()
Filename: C:\xampp\htdocs\yournameweb\application\views\include\head.php
Line Number: 4
Backtrace:
File: C:\xampp\htdocs\yournameweb\application\views\index.php
Line: 8
Function: include_once
File: C:\xampp\htdocs\yournameweb\application\controllers\Beranda.php
Line: 8
Function: view
File: C:\xampp\htdocs\yournameweb\index.php
Line: 315
Function: require_once

Solution

Kamu belum meng-load url helper di codeigniter, cara meng-load ada 2 macam
1. Load di controllernya, tambhahkan method construct di atas method index nya
public function __construct()
{
parent::__construct();
$this->load->helper('url');
}

2. Load di C:\xampp\htdocs\yournameweb\application\config edit di file autoload.php, di line 92 ubah
$autoload['helper'] = array();
menjadi
$autoload['helper'] = array('url');
*jika kita ingin automatis dan ingin sekali saja mengatur helpernya pilih opsi ke 2 karena kalau opsi pertama akan terus di bikin disetiap controller

Tested

Xampp v3.2.2
Codeigniter 3.1.4
Windows 10
Load disqus comments

0 komentar