1.2.1187. Throw

List of thrown exceptions.

<?php
if ($divisor === 0) {
    // Throw native exception
    throw new DivisionByZeroError("Shouldn't divide by one");
}

if ($divisor === 1) {
    // Throw custom exception
    throw new DontDivideByOneException("Shouldn't divide by one");
}
?>

See also Exceptions.

1.2.1187.1. Specs

Short name

Php/ThrowUsage

Rulesets

All, Appinfo, CE

Exakat since

0.8.4

PHP Version

All

Severity

Time To Fix

Precision

Very high

Features

exception, try-catch

Available in

Entreprise Edition, Community Edition, Exakat Cloud