ArithmeticError
(PHP 7, PHP 8)
はじめに
ArithmeticError
は、数学的な操作でエラーが発生した場合にスローされます。
たとえばマイナスのビットシフトを行おうとした場合などに発生します。
また、結果が int の範囲をこえてしまうような
intdiv() の呼び出しの際にも発生します。
クラス概要
class ArithmeticError
extends
Error
{
/* 継承したプロパティ */
/* 継承したメソッド */
}
nima dot shirinzadeh at gmail dot com ¶ 5 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
?>