PHP 8.5.0 Beta 3 available for testing

ArithmeticError

(PHP 7, PHP 8)

EinfΓΌhrung

ArithmeticError wird geworfen, wenn bei einer mathematischen Operation ein Fehler auftritt. Das ist z. B. der Fall, wenn versucht wird, eine Bitverschiebung um einen negativen Betrag durchzufΓΌhren, oder wenn ein Aufruf von intdiv() zu einem Wert außerhalb des mΓΆglichen Bereichs von int fΓΌhren wΓΌrde.

Klassenbeschreibung

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 */
public Error::__construct(string $message = "", int $code = 0, ?Throwable $previous = null)
final public Error::getMessage(): string
final public Error::getCode(): int
final public Error::getFile(): string
final public Error::getLine(): int
final public Error::getTrace(): array
private Error::__clone(): void
}
οΌ‹add a note

User Contributed Notes 1 note

up
-1
nima dot shirinzadeh at gmail dot com ΒΆ
4 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