ArithmeticError

(PHP 7, PHP 8)

Введение

ArithmeticError выбрасывается, когда возникает ошибка при выполнении математических операций. Такие ошибки возможно спровоцировать побитовым смещением на отрицательное значение, или вызовом функции intdiv(), приводящей значение, не входящее в допустимый интервал целых чисел (int).

Обзор классов

ArithmeticError implements Error {
/* Наследуемые свойства */
protected string $message;
protected int $code;
protected string $file;
protected int $line;
/* Наследуемые методы */
final public Error::getMessage(): string
final public Error::getPrevious(): Throwable|null
final public Error::getCode(): int
final public Error::getFile(): string
final public Error::getLine(): int
final public Error::getTrace(): array
final public Error::getTraceAsString(): string
public Error::__toString(): string
final private Error::__clone(): void
}
add a note add a note

User Contributed Notes 1 note

up
1
nima dot shirinzadeh at gmail dot com
3 years ago
the first example shifted by the positive number and the result is 4, but the second example shifted by the negative number and the result is ArithmeticError(this example is the same for left shift)
<?php

$shif
=1;
$number = 8;
$result $number >> $shif;
echo
$result; //// 1000 >> 01000 = 4

$shif =-1;
$number = 8;
$result $number >> $shif;
////result is ArithmeticError
?>
To Top