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
}
īŧ‹add a note

User Contributed Notes 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
?>