PHP 8.5.0 Alpha 1 available for testing

Voting

: two plus three?
(Example: nine)

The Note You're Voting On

Jakub
8 years ago
I see this in this way:
By definiton, OutOfRangeException should be use to when potential problem is logical - occurs because of wrong code or definition. OutOfBoundsException is for runtime.

Example (see also note in "OutOfBoundsException class" article):
<?php
function prepareData(PDOStatement $s) {
$x = $s->fetch();
if (!isset(
$x['secretColumn']))
throw new
OutOfRangeException ("Secret column doesn't exist! Verify table definition and query.");
}

<< Back to user notes page

To Top