PHP 8.0.26 Released!

La clase UnderflowException

(PHP 5 >= 5.1.0, PHP 7, PHP 8)


Lanza una excepción cuando se lleva a cabo una operación no válida o un contenedor vacío, tal como eliminar un elemento.

Sinopsis de la Clase

class UnderflowException extends RuntimeException {
/* Propiedades heredadas */
protected string $message;
protected int $code;
protected string $file;
protected int $line;
/* Métodos heredados */
public Exception::__construct(string $message = "", int $code = 0, Throwable $previous = null)
final public Exception::getMessage(): string
final public Exception::getCode(): mixed
final public Exception::getFile(): string
final public Exception::getLine(): int
final public Exception::getTrace(): array
final public Exception::getTraceAsString(): string
public Exception::__toString(): string
final private Exception::__clone(): void
add a note

User Contributed Notes 2 notes

Jakub Adamczyk
4 months ago
The most typical usage is with stack, queue or collection, for example when you queue tasks, make call stack or manipulate JSON, XML, etc. elements.

As other exepctions of RuntimeException class, this type of error can't be detected in (for example) your IDE or compiler.

// Functions declared above
$f1 = function() { setTypeControl('username');};
$f2 = function() { setTypeControl('userpass');};
$f3 = function() { setButton('Add');};
$f4 = function() { setButton('OK');};

$tasks = new class {

// Create internal queue
public function __construct() {
$this->list = new SplQueue;

// Add to queue
public function add(callable $func) {

// Delete from queue and execute
public function do() {
        if (
$this->list->isEmpty()) {
            throw new
        } else {



$tasks->do(); // Field username is created
$tasks->do(); // Field userpass is created
$tasks->do(); // Button Add is created
$tasks->do(); // Button OK is created
$tasks->do(); // Fatal error: Uncaught UnderflowException in ...
evguenia dot chagnon at gmail dot com
5 years ago
UnderflowException handles exceptions due to a value being too small to maintain precision, resulting in loss of accuracy. In PHP, this can occurs when using floats:

echo (1-0.9) // 0.1
echo (1-0.99) // 0.01
echo (1-0.999) // 0.001
echo (1-0.9999) // 9.9999999999989E-05
echo (1-0.99999) // 9.9999999999545E-06
echo (1-0.999999) // 1.0000000000288E-06
To Top