The OutOfRangeException class

(PHP 5 >= 5.1.0, PHP 7)

Introduzione

Exception thrown when an illegal index was requested. This represents errors that should be detected at compile time.

Sommario dellla classe

OutOfRangeException extends LogicException {
/* Proprietà ereditate */
protected string $message ;
protected int $code ;
protected string $file ;
protected int $line ;
/* Metodi ereditati */
final public string Exception::getMessage ( void )
final public Throwable Exception::getPrevious ( void )
final public mixed Exception::getCode ( void )
final public string Exception::getFile ( void )
final public int Exception::getLine ( void )
final public array Exception::getTrace ( void )
final public string Exception::getTraceAsString ( void )
public string Exception::__toString ( void )
final private void Exception::__clone ( void )
}
add a note add a note

User Contributed Notes 2 notes

up
1
Jakub
6 months 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.");
}
up
1
evguenia dot chagnon at gmail dot com
9 months ago
Exemple :

$calendar = new Calendar();
$calendar->getMonth(15);
To Top