PHP 8.1.2 Released!


(PHP 7, PHP 8)


ArithmeticError is thrown when an error occurs while performing mathematical operations. These errors include attempting to perform a bitshift by a negative amount, and any call to intdiv() that would result in a value outside the possible bounds of an int.


class ArithmeticError extends Error {
/* Geerbte Eigenschaften */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private ?Throwable $previous = null;
/* Geerbte Methoden */
final public Error::getMessage(): string
final public Error::getPrevious(): ?Throwable
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
private Error::__clone(): void
add a note add a note

User Contributed Notes 1 note

nima dot shirinzadeh at gmail dot com
1 year 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)

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

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