base_url() function won't work on error pages. Even after autoloading
<p>I want to have nice good looking error pages. For this I need to get some CSS and JS files. But for some odd reason using <code>base_url()</code> does not work on the error_pages. I could of course just use <code>href=&quot;/css/style.css&quot;</code> and tell it to get it from the root folder. But the website could very well be put in a different folder than the root folder. So using the <code>/</code> is not an option.</p>
<p>So my question now is why doesn't <code>base_url()</code> work on an error page? I have autoloaded it so shouldn't it be working?</p>
<p>This is what I tried when I was trying to get the base_url() from the error_404 page in the view.</p>
<p>In my autoload.php I have included the helper <code>url</code></p>
<pre><code>$autoload['helper'] = array('url', 'form');
</code></pre>
<p>And in my error_404 page (application/views/errors/html/error_404.php) I am echoing the base_url like so:</p>
<p><code>&lt;?php echo base_url(); ?&gt;</code></p>
<p>This is the error I'm getting:</p>
<pre><code>An uncaught Exception was encountered

Type: Error

Message: Call to undefined function base_url()

Filename: /usr/local/www/example.com/application/views/errors/html/error_404.php

Line Number: 37

Backtrace:

    File: /usr/local/www/example.com/index.php
    Line: 315
    Function: require_once
</code></pre>
<p>I'd rather not make any changes in the <code>system</code> folder since I don't want to redo the process every time I update Codeigniter folder.</p>
<p>System:</p>
<blockquote>
<p>Codeigniter 3.0.6</p>
<p>PHP 7.0.8</p>
<p>Nginx 1.11.1</p>
</blockquote>
<p><strong>UPDATE:</strong>
I'd like to call base_url on every error page (db, 404, general, php, etc.).</p>