致命错误:调用未定义的函数 site_url()
我正在使用 PHP 的 CodeIgniter 框架。我创建了一个名为“login.php”的视图。 创建视图后
,我将视图加载到名为“index”的函数内,该函数位于
扩展控制器的名为“CCI”的类内,但我不断收到此错误:致命
错误:调用未定义的函数 site_url()在 C:\wamp\www\FinalP_CCI_Clone\system
\application\views\login.php 第 12 行。我不明白我遇到的问题,因为
欢迎页面加载正常,而我的第二个函数位于“CCI”类中负载也很好。
这是一些代码:
控制器文件:
function CCI()
{
parent::Controller();
}
function index()
{
$this->load->view('login');
}
function test()
{
echo "Testing Data";
}
}
/* login.php 文件结尾 / / 位置:./system/application/controllers/cci.php */
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index()
{
$this->load->view('welcome_message');
}
function test()
{
echo "Testing Data";
}
}
/* 文件结尾welcome.php / / 位置:./system/application/controllers/welcome.php */
I am using the CodeIgniter framework for PHP. I have created a view named "login.php". Once I
created the view, I then loaded the view inside of a function named "index" which is located
inside a class named "CCI" that extends the Controller but I keep receiving this error: Fatal
error: Call to undefined function site_url() in C:\wamp\www\FinalP_CCI_Clone\system
\application\views\login.php on line 12. I don't understand the issue I an having because the
welcome page loads fine and my second function inside of the "CCI" class loads fine as well.
Here is some of the code:
Controller Files:
function CCI()
{
parent::Controller();
}
function index()
{
$this->load->view('login');
}
function test()
{
echo "Testing Data";
}
}
/* End of file login.php /
/ Location: ./system/application/controllers/cci.php */
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index()
{
$this->load->view('welcome_message');
}
function test()
{
echo "Testing Data";
}
}
/* End of file welcome.php /
/ Location: ./system/application/controllers/welcome.php */
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须加载助手。函数
site_url()
由url
帮助器提供,如此处所述。You have to load the helper. The function
site_url()
is provided by theurl
helper, as described here.您可以尝试以下操作:
首先加载 URL 帮助程序:
$this->load->helper('url');
或在application/config/autoload.php
中设置以下值$autoload['helper'] = array('url');
base_url()
(结果:http://example.com/)或site_url()
(结果:http://example.com/index.php php/)注意:结果取决于
application/config/config.php
中存储的值You can try this:
First Load the URL Helper with:
$this->load->helper('url');
or set the following value inapplication/config/autoload.php
$autoload['helper'] = array('url');
base_url()
(result: http://example.com/) orsite_url()
(result: http://example.com/index.php/)Note: Results depends on values stored in
application/config/config.php