1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/bcmath/tests/number/operators/mod_by_zero.phpt
Saki Takamachi fad899e566 [RFC] Support object types in BCMath (#13741)
Added BcMath\Number class. It is an immutable object, has methods that are
equivalent to existing BCMath calculation functions, and can also be calculated
using operators.

The existing BCMath function returned a string for each calculation, but this
class returns an object.

RFC: https://wiki.php.net/rfc/support_object_type_in_bcmath,
https://wiki.php.net/rfc/fix_up_bcmath_number_class

---------

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2024-09-04 11:12:51 +09:00

54 lines
753 B
PHP

--TEST--
BcMath\Number mod by zero by operator
--EXTENSIONS--
bcmath
--FILE--
<?php
$num = new BcMath\Number(100);
try {
$num % 0;
} catch (Error $e) {
echo $e->getMessage() . "\n";
}
try {
$num % '0';
} catch (Error $e) {
echo $e->getMessage() . "\n";
}
try {
$num % (new BcMath\Number(0));
} catch (Error $e) {
echo $e->getMessage() . "\n";
}
$zero = new BcMath\Number(0);
try {
100 % $zero;
} catch (Error $e) {
echo $e->getMessage() . "\n";
}
try {
'100' % $zero;
} catch (Error $e) {
echo $e->getMessage() . "\n";
}
try {
$num % $zero;
} catch (Error $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
Modulo by zero
Modulo by zero
Modulo by zero
Modulo by zero
Modulo by zero
Modulo by zero