php从另一个函数中的私有函数返回FALSE

In my Codeigniter controller have the following private function which validates file uploads.

     private function avatar_file_validation()
     {
        $config['upload_path'] = './uploads/avatars/';
        $config['allowed_types'] = 'jpg|png';
        $config['overwrite'] = TRUE; //overwrite user avatar
        $config['max_size'] = '800'; //in KB

        $this->load->library('upload', $config);

        if (! $this->upload->do_upload('avatar_upload'))
        {
            $error_data = array('error' => $this->upload->display_errors());

            $this->avatar_view($error_data); //loads view

            return FALSE;
        }

     }

if an error occurs in uploading I want to stop this function from continuing

function upload_avatar()
{

    //some code

    if($_FILES['entry_upload']['error'] !== 4) //if file added to file field
    {
        $this->avatar_file_validation(); //if returns FALSE stop code
    }

    //code continues: adds data to database, redirects

}

However the function continues even when returning false. It works only when I use the entire code in 1 function but I need to separate them as I'll be using the upload validation in multiple functions. What am I doing wrong here?

The expression return FALSE; only applies to the function avatar_file_validation(). If you want to stop the code in upload_avatar() when the upload fails, you should check the output of avatar_file_validation() and if it equals FALSE, return from that function as well.

For example:

function upload_avatar()
{
    //some code

    if($_FILES['entry_upload']['error'] !== 4) //if file added to file field
    {
        if(!$this->avatar_file_validation()) //if returns FALSE stop code
            return FALSE;
    }

    //code continues: adds data to database, redirects
}
function upload_avatar()
{

    //some code

    if(!$_FILES['entry_upload']['error'] !== 4) //if file added to file field
    {
        if($this->avatar_file_validation()){
             return FALSE;
         }
    }

    //code continues: adds data to database, redirects

}