CodeIgniter-超链接创建


CodeIgniter - Hyperlink creation

我曾尝试使用锚点创建到另一个页面的超链接,但似乎不起作用。我的函数名为calendar,它存储在controllers目录下的calcontrol.php中。

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Calendar extends CI_Controller{
public function __construct()
{
    parent::__construct();
    $this->load->helper('url');
}
public function index()
{
    $this->load->view('calendar');
}
}
?>

我试过其他方法,但似乎不起作用。

编辑:这是我的a href<a href="<?php echo site_url('calcontrol/calendar') ?>">Link</a>

文件名和类名必须相同,否则CI将无法加载它。如果使用CI 3,请确保类名和文件名都是Ucfirst。如果你把所有东西都设置成这样,那么你应该能够通过http://yourdomain.com/calendar/calendar

试试这个代码。您忘记加载url帮助程序。File Calendar.php-noice大写C if CI3:

 <?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Calendar extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->helper('url');
    }
    public function index()
    {
        $this->load->view('calendar');
    }
}