0
Using this code snippet as an example, the function die() could replace Return and Exit? It may have the same functioning as Return?
public function error()
{
if(!$this->connection || !$this->statement) {
return (object) array(
'exception' => $this->connection->errno,
'error' => $this->connection->error
);
exit;
}
}
dieandexitare synonyms and it cannot replacereturn, otherwise PHP would terminate the application instead of returning the value. Ps.: If you want to return the value, theexitis unnecessary in this method; if you want to terminate the application, thereturnwould become unnecessary.– Valdeir Psr
Relacioanda: What is the difference between die, Exit and __halt_compiler?
– rray
By the way
exitwill never be executed, as thereturnis out of function.– Lucas