CodeIgniter Forums
url_helper error/bug - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: url_helper error/bug (/showthread.php?tid=63069)



url_helper error/bug - tkaratug - 09-22-2015

Hi everyone,

I am trying to use current_url() function on my localhost but getting this error below;

PHP Code:
Call to a member function uri_string() on null in /opt/lampp/htdocs/ci_3/system/helpers/url_helper.php on line 106 

I loaded the url helper with in config/autoload.php. segment() function also getting the same error. My php version is 5.6.12, so is that the reason of the problem? How can i fix this error?

Here is my controller and view files.

controllers/Home.php:
PHP Code:
class Home extends CI_Controller {

    function 
__construct()
    {
        
parent::__construct();
        
$this->load->helper('url');
    }

    public function 
index()
    {
        
$data['title'] = 'Test';
        
$this->load->view('home_view',$data);
    }



views/home_view.php:
PHP Code:
<!DOCTYPE html>
<
html lang="en">
<
head>
    <
meta charset="UTF-8">
    <
title><?php echo $title?></title>
</head>
<body>
    <h2>Hello World!</h2>
    <p><?php echo current_url(); ?></p>
</body>
</html> 



RE: url_helper error/bug - Narf - 09-23-2015

We don't need the same threads posted twice ... http://forum.codeigniter.com/thread-63047.html
It won't help you, but will just confuse others.