Signatur
throw new Exception(…);
Beschreibung
Die Kontrolle springt zum nächsten passenden catch-Block.
Rückgabewert
Typ
never
Beispiele
Klassisch
<?php
if (!$user) {
throw new NotFoundException("User $id nicht da");
}
Als Ausdruck (PHP 8+)
<?php
$user = User::find($id) ?? throw new NotFoundException("User $id");