ArithmeticError

(PHP 7)

Wstęp

ArithmeticError jest rzucany gdy wystąpi błąd podczas wykonywania opracji matematycznych. W PHP 7.0, do tych błędów zalicza się próba przesunięcia bitowego o wartość ujemną i każde wywołanie intdiv(), którego wynikiem będzie wartość poza możliwymi granicami typu integer.

Krótki opis klasy

ArithmeticError extends Error {
/* Właściwości dziedziczone */
protected string $message ;
protected int $code ;
protected string $file ;
protected int $line ;
/* Metody dziedziczone */
final public Error::getMessage ( void ) : string
final public Error::getPrevious ( void ) : Throwable
final public Error::getCode ( void ) : mixed
final public Error::getFile ( void ) : string
final public Error::getLine ( void ) : int
final public Error::getTrace ( void ) : array
final public Error::getTraceAsString ( void ) : string
public Error::__toString ( void ) : string
final private Error::__clone ( void ) : 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