Function function die () [duplicate]

0

Using this snippet of code as an example, could the die () function override the return and exit? Can it have same return operation?

public function error()
{
    if(!$this->connection || !$this->statement) {
        return (object) array(
            'exception' => $this->connection->errno,
            'error' => $this->connection->error
        );
        exit;
    }
}
    
asked by anonymous 19.03.2018 / 13:03

1 answer

0

No, it can not override the return, the return is the answer to what happened inside the function, because in the exception house you should treat it where it called the function, an example is when something is false or true, when you call a function and it does not occur as due, usually it returns false, eg:

 if(função){
    //Ocorreu com sucesso
 }else{
    //Deu algum erro
    die('Algum erro ocorreu!');
 }
    
19.03.2018 / 14:50