1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Codeigniter: Call to undefined function base_url()

Discussion in 'General PHP and MySQL Discussions' started by Claudio, Jul 31, 2016.

  1. Claudio

    Claudio Well-Known Member

    Hi,

    I get this error when I try to load base_url funcion. The problem is that I've already added base_url to autoload file but the issue still:
    Code:
    $autoload['helper'] = array('url');
    views/home.php file has the following code:
    Code:
    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
    </head>
    <body>
    <div align="center">
        <h1>Index</h1>
        <a href="<?= base_url()?>">Link</a>
    </div>
    
    </body>
    </html>
    Any ideas? Since base_url function is being loaded by autoload I don't know what else should I try to do to fix this.

    Thank you!
     
  2. ugurkn

    ugurkn Member

    Please try to add $this->load->helper("url") to the __construct() of your controller.
     

Share This Page