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>