PHP 7.2.0 Release Candidate 4 Released

La clase OutOfRangeException

(PHP 5 >= 5.1.0, PHP 7)

Introducción

Lanza una excepción cuando se solicita un índice ilegal. Esto representa un error que debe ser detectado en tiempo de compilación.

Sinopsis de la Clase

OutOfRangeException extends LogicException {
/* Propiedades heredadas */
protected string $message ;
protected int $code ;
protected string $file ;
protected int $line ;
/* Métodos heredados */
final public string Exception::getMessage ( void )
final public Exception 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
5 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
8 months ago
Exemple :

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