How do I use the relative link in codeigniter?

I have the following code in Controller:

class Home extends CI_Controller
{

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

    function index()
    {
        $this->load->view('layout');

    }

    function about()
    {
        $this->load->view('about');
    }
}

If I want to create a relative link to about, how do I accomplish that? The following link in view doesn’t always work. What is apporpiate way to about relative links in CodeIngiter?

  • <a href=""> About
  • I believe that the reason your view code doesn’t work is most likely due to not autoloading the URL Helper.

    If you add the ‘url’ to the Autoloader ( http://ellislab.com/codeigniter/user-guide/general/autoloader.html
    ) the function site_url
    will become available on all controllers, views, and models.

    File to edit: application / config / autoload.php

    Line 110

    Example of what it should look like (assuming you aren’t auto-loading any other helpers):

    $autoload['helper'] = array('url');

    Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

    本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
    酷辣虫 » 综合编程 » How do I use the relative link in codeigniter&quest;

    喜欢 (0)or分享给?

    专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

    使用声明 | 英豪名录