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;
}
}
die
andexit
are synonyms and it cannot replacereturn
, otherwise PHP would terminate the application instead of returning the value. Ps.: If you want to return the value, theexit
is unnecessary in this method; if you want to terminate the application, thereturn
would become unnecessary.– Valdeir Psr
Relacioanda: What is the difference between die, Exit and __halt_compiler?
– rray
By the way
exit
will never be executed, as thereturn
is out of function.– Lucas