你能给助手一个变量,并改变它在CodeIgniter中使用的功能

I am creating a form and I want to make a custom error log, for example when the user leaves e-mail empty, I want to give my error_helper the variable email, sending to the user that he did not fill in this variable and log that he left this empty. I am a starter with codeIgniter and i've read the manual but I did not find anything helpful. Here is my code:

    public function submitCheck() {
    $this->load->model("User");
    if(empty($post['email'] || 'email'==""))
    {
        echo "Email is empty."; //This will be changed to a view for user    
        $this->load->helper('error'); //Loading the helper
        errorLog('Firstname'); //Variable I want to give to the errorLog function.
        exit();
    }    

So here I've given my errorLog a variable, wich I want to use in my error_helper

    function errorLog(){         
     if(errorLog() == 'email') //Here I want to change the error function based on what variable I give to errorLog
     {
        log_message('error', 'Email was empty');
        exit();
     }
}  

Is this possible to do or some other way how I can change the function based on what variable I give my errorLog. Thanks in advance

You need to pass parameter into your helper function

Controller file

public function submitCheck() {
    $this->load->model("User");
    if(empty($post['email']))
    {
       // echo "Email is empty."; //This will be changed to a view for user    
        $this->load->helper('error'); //Loading the helper
     echo  $msg= errorLog('Firstname'); //Variable I want to give to the errorLog function.
    }  

Helper file

    function errorLog($var){ // get the variable thet you have pass from your helper        
         if($var == 'email') //Here I want to change the error function based on what variable I give to errorLog
         {
            return log_message('error', 'Email was empty');// here you use return type

         }
         if($var == 'test') 
         {
            return log_message('error', 'Test was empty');// here you use return type

         }
}

Also load your helper in controller constructor file or autoload.php file

Read parameter in the function:

    function errorLog($var){         
     if($var== 'email') //Here I want to change the error function based on what variable I give to errorLog
     {
        log_message('error', 'Email was empty');
        exit();
     }
}