【发布时间】:2015-11-30 02:17:32
【问题描述】:
我在 CI 上有这样的控制器
class Testing extends CI_Controller {
//put your code here
public function xx() {
$this->load->helper('url');
$this->load->view('testing');
}
public function linkURL() {
$this->load->helper('url');
$data['test'] = "testing123";
$this->load->view('xxx_view', $data);
}
}
我在函数linkURL上运行并调用view xxx_view,view上的代码是这样的
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
$segment = array('Testing', 'xx');
?>
<a href="<?php echo site_url($segment); ?>">Link</a>
</body>
查看调用href并使用帮助程序site_url调用控制器测试和函数xx。但是链接不起作用。我已经在萤火虫上捕捉到了,链接看起来很奇怪。 href 上的链接包含*http://::1*。如何解决该链接
【问题讨论】:
-
当您的链接以
http://::1开头时,请确保您已设置基本网址配置$config['base_url'] = 'http://localhost/project/' -
我会自动加载 url 帮助程序,这样你就不会加倍代码。