Site_url does not work in Codeigniter

Asked

Viewed 280 times

2

I’m following a tutorial of Codeigniter this snippet of code is not working on my machine, I’ve set everything right, even the other tutorials have worked, but this snippet of code is not working:

<a href="<?php echo site_url()?>sobre">Sobre</a>

In the tutorial worked cool, but here not.

  • Actually, this is loading the url helper? $this->load->helper('url'). And I usually put the link inside the parentheses, even working outside, I think it looks better visually! <a href="<?php echo site_url('sobre')?>">Sobre</a>

  • How do I load the URL Helper? Marcelo.

  • Within View itself or Controller?

  • Or you can upload it to your application/autoload.php file or controller. If it’s autoload . $autoload['helper'] = array('url', 'html'); , if in controller $this->load->helper('url');

  • Create there the answer I will mark as the right answer.

1 answer

1


You must load the url helper, either in autoload or in the controller:

If it’s on autoload application/autoload.php look for $autoload['helper'] = array('url');

If on the controller $this->load->helper('url');

  • Thank you Marcelo Diniz

Browser other questions tagged

You are not signed in. Login or sign up in order to post.