PHP 8.5.8 Released!

ArithmeticError

(PHP 7, PHP 8)

简介

当执行数学运算发生错误时抛出 ArithmeticError 。 这些错误包括尝试执行负数的位移,以及对任何可能会导致值超出 int 的范围 intdiv() 调用。

类摘要

class ArithmeticError extends Error {
/* 继承的属性 */
protected string $message = "";
private string $string = "";
protected int $code ;
protected string $file = "";
protected int $line ;
private array $trace = [];
private ?Throwable $previous = null;
/* 继承的方法 */
public function Error::__construct (string $message = "", int $code = 0, ? Throwable $previous = null )
final public function Error::getMessage (): string
final public function Error::getPrevious (): ? Throwable
final public function Error::getCode (): int
final public function Error::getFile (): string
final public function Error::getLine (): int
final public function Error::getTrace (): array
final public function Error::getTraceAsString (): string
public function Error::__toString (): string
private function Error::__clone (): void
}

发现了问题?

了解如何改进此页面提交拉取请求报告一个错误
+添加备注

用户贡献的备注 1 note

up
-1
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
?>
+添加备注

AltStyle によって変換されたページ (->オリジナル) /