PHP 8.5.0 Beta 3 available for testing

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 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