这是我的控制器功能,因为我可以看到没有错误,但它仍然向我显示此消息。它是什么意思。
<?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); } } }
显示此错误。
/usr
答案 0 :(得分:0)
使用此行
'lastname'=>$fullnameSplit[2],
as
'lastname'=>isset($fullnameSplit[2]) ? $fullnameSplit[2] : '',
错误未定义offet:2表示带有键[2]的数组$ fullnameSplit不存在或未设置。所以你需要检查条件isset()以避免该消息