PHP

Exceptions in PHP (try, catch, finally)

Në shqip: Përjashtimet në PHP

ShpjegimiSQ

Në PHP i kap gabimet me try/catch, dhe finally ekzekutohet gjithmonë. Hedh gabime me throw new Exception("..."), dhe mund të krijosh llojet e tua duke trashëguar nga Exception.

EnglishEN

In PHP you catch errors with try/catch, and finally always runs. You throw errors with throw new Exception("..."), and you can create your own types by extending Exception.

Si ta mendosh

Si portieri pas mbrojtjes.

Lexoje në anglisht

Like the goalkeeper behind the defence.

Shembull kodiphp

try {
  $pdo = new PDO($dsn, $user, $pass);
} catch (PDOException $e) {
  echo "S'u lidh databaza: " . $e->getMessage();
}

Terma të lidhur