php 致命错误:在 c 中调用未定义的函数 form_open()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15063174/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fatal error: Call to undefined function form_open() in c
提问by Edvinas Liutvaitis
i got this error and daunt know where i went wrong i am new to codeigniter so i am sure its something stupid can anyone figure this out tnx in advance.
我遇到了这个错误,我很害怕知道我哪里出错了,我是 codeigniter 的新手,所以我确信它有些愚蠢,任何人都可以提前弄清楚 tnx。
create_view.php
创建视图.php
<body>
<?php echo form_open('create'); ?>
<ul id="accordion">
<li>
<a>Survey Creation</a>
<ul id="survay">
<li>Enter a question:<?php echo form_input('Question')?></li>
<li>Answer A: <?php echo form_input('qA' );?></li>
<li>Answer B: <?php echo form_input('qB' );?></li>
<li>Answer C: <?php echo form_input('qC' );?></li>
<li><?php echo form_submit('submit', 'Set This Question' );?></li>
</ul>
</li>
create.php
创建.php
<?php
class Create extends CI_Controller{
function index(){
$this->load->view('create_view');
}
// insert data
function create1()
{
$data = array(
'Question' => $this->input->post('Question'),
'qA' => $this->input->post('qA'),
'qB' => $this->input->post('qB'),
'qC' => $this->input->post('qC'),
);
$this->create_model->add_record($data);
$this->home();
}
}
?>
回答by complex857
Seems like you forgot to load the form helper. Use the application/config/autoload.phpor add the following line into your controller before loading the view:
好像你忘记加载表单助手了。application/config/autoload.php在加载视图之前使用或将以下行添加到您的控制器中:
$this->load->helper('form');
回答by user3645541
You may also load this helpers on all controllers. Go your config folder and open autoload.php in any editor and then load required helper as following :
您还可以在所有控制器上加载此帮助程序。转到您的配置文件夹并在任何编辑器中打开 autoload.php,然后按如下方式加载所需的帮助程序:
$autoload['helper'] = array('url','form');
回答by Rameez SOOMRO
Load your CI helper in your controller $this->load->helper('form');
在控制器中加载 CI 助手 $this->load->helper('form');
class Create extends CI_Controller{
function index(){
$this->load->view('create_view');
$this->load->helper('form');
or make auto load helpers on all contollers. Open application/config/autoload.php
或在所有控制器上制作自动加载助手。打开 application/config/autoload.php
$autoload['helpers'] = array('form','myhelper');
回答by Dylan B
You need to load Helper 'Form' before using this function. Add this line:
在使用此功能之前,您需要加载 Helper 'Form'。添加这一行:
$this->load->helper('form');
回答by A.Aleem11
Make sure to have following line above view called in controller:
确保在控制器中调用视图上方的以下行:
$this->load->library('form_validation'); //make sure to have it, before view call
$this->load->view('profile');

