Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 未定义偏移量:2英寸编码器点火器_Php_Codeigniter - Fatal编程技术网

Php 未定义偏移量:2英寸编码器点火器

Php 未定义偏移量:2英寸编码器点火器,php,codeigniter,Php,Codeigniter,这是我的控制器功能,据我所知,没有错误,但它仍然向我显示这条消息。这是什么意思 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class User extends CI_Controller { public function __construct() { parent::__construct(); //

这是我的控制器功能,据我所知,没有错误,但它仍然向我显示这条消息。这是什么意思

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

     class User extends CI_Controller {

    public function __construct()
    {
            parent::__construct();
            // Your own constructor code

            //$this->load->model('user_model');
    }

    public function index()
    {
        $this->load->view('user/signup');
    }
    public function registration()
    {

        if($this->input->post())
        {
            $fullname=$this->input->post('fullname');
            $fullnameSplit= explode(" ", $fullname);

            $reg_data = array(
                'membershipid'=>"Ls-".rand(),
                'role'=>1,
                'firstname'=>$fullnameSplit[0],
                'middlename'=>$fullnameSplit[1],
                'lastname'=>$fullnameSplit[2],
                'Company_name'=>$this->input->post('companyname'),
                'email'=>$this->input->post('email'),
                'password'=>sha1($this->input->post('password')),

            );
            print_r($reg_data);
            //$this->user_model->register_user($reg_data);
            //redirect('user/login');

            //echo '<pre>'; print_r($reg_data); die;


        }else 
        {

            //$data['current_page'] = 'Register';
            //$this->load->view('registration',$data);
        }
    }


}
使用这一行

作为


错误undefined OFET:2表示键为[2]的数组$fullnameSplit不存在或未设置。因此,您需要检查条件isset()以避免出现这样的消息

用户控制器中的php标记上方是否有空格?如果是,请删除不需要的空格,也只需注释
print\r($reg\u data)不依赖于用户输入。始终制作虚拟验证代码。最好的方法应该是有更多的输入字段,即
$f_name
$m_name
$l_name
,并且在控制器中检查这些字段是否为空,然后再使用它们。 A PHP Error was encountered Severity: Notice Message: Undefined offset: 2 Filename: controllers/User.php Line Number: 35 Backtrace: File: /var/www/overtribe.com/public_html/listspread/application/controllers/User.php Line: 35 Function: _error_handler File: /var/www/overtribe.com/public_html/listspread/index.php Line: 293 Function: require_once
'lastname'=>$fullnameSplit[2],
'lastname'=>isset($fullnameSplit[2]) ? $fullnameSplit[2] : '',