Commit b90212aa0f5 for php

commit b90212aa0f564ee700eec42e728f5f4aa26eb1fe
Author: Sjoerd Langkemper <sjoerd-github@linuxonly.nl>
Date:   Wed Nov 4 13:41:48 2026 +0000

    ext/standard: throw exception for invalid characters for number base

    This is about the situation where a character is not within the
    specified number base. E.g. only 0-9, a-f are allowed for hexadecimal,
    so what should `hexdec('z')` do?

    In the past, such characters were silently ignored. Since PHP 7.4 a
    deprecation notice would be generated. This commit changes that to an
    Exception.

    RFC: https://wiki.php.net/rfc/throw_error_for_invalid_characters_for_number_base

    Close GH-22365

diff --git a/NEWS b/NEWS
index 78f010b74ce..30fdbb91de1 100644
--- a/NEWS
+++ b/NEWS
@@ -189,6 +189,9 @@ PHP                                                                        NEWS
     especially UTF-8. (Nicolas Grekas)
   . Improved performance of htmlspecialchars() when nothing needs encoding.
     (Nicolas Grekas)
+  . bindec(), octdec(), hexdec() and base_convert() now throw an Exception
+    when the passed string contains characters that are invalid for the
+    specified number base. (Sjoerd Langkemper)

 - URI:
   . Fix casing of enum cases in UriHostType and UrlHostType to match the RFC
diff --git a/UPGRADING b/UPGRADING
index a1e30018cd6..d91fda65368 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -57,6 +57,9 @@ PHP 8.7 UPGRADE NOTES
     application terminate one attribute and append further ones.

 - Standard:
+  . bindec(), octdec(), hexdec() and base_convert() now throw an Exception
+    when the passed string contains characters that are invalid for the
+    specified number base.
   . The number of filters that can be chained in a php://filter URL is limited
     to 16 by default. Set the stream context option max_filter_count to change
     this.
diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS
index c94b605c5c9..b5f75747ef7 100644
--- a/UPGRADING.INTERNALS
+++ b/UPGRADING.INTERNALS
@@ -91,6 +91,9 @@ PHP 8.7 INTERNALS UPGRADE NOTES
 - Standard:
   . php_explode() now takes a HashTable* instead of a zval* to store the
     resulting parts. It already expected the zval* to be IS_ARRAY.
+  . _php_math_basetozval() now returns zend_result instead of void. It throws
+    an exception and returns FAILURE if the input contains invalid characters
+    for the given base.

 ========================
 4. OpCode changes
diff --git a/ext/standard/math.c b/ext/standard/math.c
index 20286870c7c..ed324f239d2 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -850,7 +850,7 @@ PHPAPI zend_long _php_math_basetolong(zval *arg, int base)
 /*
  * Convert a string representation of a base(2-36) number to a zval.
  */
-PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret)
+PHPAPI zend_result _php_math_basetozval(zend_string *str, int base, zval *ret)
 {
 	zend_long num = 0;
 	double fnum = 0;
@@ -858,7 +858,7 @@ PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret)
 	char c, *s, *e;
 	zend_long cutoff;
 	int cutlim;
-	int invalidchars = 0;
+	bool invalidchars = false;

 	s = ZSTR_VAL(str);
 	e = s + ZSTR_LEN(str);
@@ -888,13 +888,13 @@ PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret)
 		else if (c >= 'a' && c <= 'z')
 			c -= 'a' - 10;
 		else {
-			invalidchars++;
-			continue;
+			invalidchars = true;
+			break;
 		}

 		if (c >= base) {
-			invalidchars++;
-			continue;
+			invalidchars = true;
+			break;
 		}

 		switch (mode) {
@@ -903,7 +903,6 @@ PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret)
 				num = num * base + c;
 				break;
 			} else {
-				zend_error(E_NOTICE, "Input number is larger than PHP_INT_MAX, precision has been lost in conversion");
 				fnum = (double)num;
 				mode = 1;
 			}
@@ -913,15 +912,18 @@ PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret)
 		}
 	}

-	if (invalidchars > 0) {
-		zend_error(E_DEPRECATED, "Invalid characters passed for attempted conversion, these have been ignored");
+	if (invalidchars) {
+		zend_throw_exception(NULL, "Invalid characters passed for attempted conversion", 0);
+		return FAILURE;
 	}

 	if (mode == 1) {
+		zend_error(E_NOTICE, "Input number is larger than PHP_INT_MAX, precision has been lost in conversion");
 		ZVAL_DOUBLE(ret, fnum);
 	} else {
 		ZVAL_LONG(ret, num);
 	}
+	return SUCCESS;
 }
 /* }}} */

@@ -1039,7 +1041,9 @@ PHP_FUNCTION(bindec)
 		Z_PARAM_STR(arg)
 	ZEND_PARSE_PARAMETERS_END();

-	_php_math_basetozval(arg, 2, return_value);
+	if (SUCCESS != _php_math_basetozval(arg, 2, return_value)) {
+		RETURN_THROWS();
+	}
 }
 /* }}} */

@@ -1052,7 +1056,9 @@ PHP_FUNCTION(hexdec)
 		Z_PARAM_STR(arg)
 	ZEND_PARSE_PARAMETERS_END();

-	_php_math_basetozval(arg, 16, return_value);
+	if (SUCCESS != _php_math_basetozval(arg, 16, return_value)) {
+		RETURN_THROWS();
+	}
 }
 /* }}} */

@@ -1065,7 +1071,9 @@ PHP_FUNCTION(octdec)
 		Z_PARAM_STR(arg)
 	ZEND_PARSE_PARAMETERS_END();

-	_php_math_basetozval(arg, 8, return_value);
+	if (SUCCESS != _php_math_basetozval(arg, 8, return_value)) {
+		RETURN_THROWS();
+	}
 }
 /* }}} */

@@ -1142,7 +1150,10 @@ PHP_FUNCTION(base_convert)
 		RETURN_THROWS();
 	}

-	_php_math_basetozval(number, (int)frombase, &temp);
+	if (SUCCESS != _php_math_basetozval(number, (int)frombase, &temp)) {
+		RETURN_THROWS();
+	}
+
 	result = _php_math_zvaltobase(&temp, (int)tobase);
 	if (!result) {
 		RETURN_THROWS();
diff --git a/ext/standard/php_math.h b/ext/standard/php_math.h
index cb0b9db2159..7988c72a385 100644
--- a/ext/standard/php_math.h
+++ b/ext/standard/php_math.h
@@ -22,7 +22,7 @@ PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, const char *de
 PHPAPI zend_string *_php_math_number_format_long(zend_long num, zend_long dec, const char *dec_point, size_t dec_point_len, const char *thousand_sep, size_t thousand_sep_len);
 PHPAPI zend_string * _php_math_longtobase(zend_long arg, int base);
 PHPAPI zend_long _php_math_basetolong(zval *arg, int base);
-PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret);
+PHPAPI zend_result _php_math_basetozval(zend_string *str, int base, zval *ret);
 PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base);

 #include <math.h>
diff --git a/ext/standard/tests/math/base_convert_basic.phpt b/ext/standard/tests/math/base_convert_basic.phpt
index bdef339f3b3..2e2ca568433 100644
--- a/ext/standard/tests/math/base_convert_basic.phpt
+++ b/ext/standard/tests/math/base_convert_basic.phpt
@@ -22,256 +22,130 @@
     for ($t= 0; $t < count($tobase); $t++) {
         echo "......to base is ", $tobase[$t], "\n";
         for ($i =0; $i < count($values); $i++){
-            $res = base_convert($values[$i],$frombase[$f],$tobase[$t]);
-            echo ".........value= ", $values[$i], " res = ", $res, "\n";
+            try {
+                $res = base_convert($values[$i],$frombase[$f],$tobase[$t]);
+                echo ".........value= ", $values[$i], " res = ", $res, "\n";
+            } catch (Exception $e) {
+                echo "E........exc= ", $e::class, ': ', $e->getMessage(), "\n";
+            }
         }
     }
 }
 ?>
---EXPECTF--
+--EXPECT--
 ...from base is 2
 ......to base is 2
 .........value= 10 res = 10
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 27 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 95 res = 0
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 10 res = 10
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 27 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 0
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 8
 .........value= 10 res = 2
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 27 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 95 res = 0
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 10 res = 2
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 27 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 0
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 10
 .........value= 10 res = 2
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 27 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 95 res = 0
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 10 res = 2
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 27 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 0
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 16
 .........value= 10 res = 2
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 27 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 95 res = 0
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 10 res = 2
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 27 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 0
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 36
 .........value= 10 res = 2
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 27 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 95 res = 0
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 10 res = 2
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 27 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 0
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 0
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion

 ...from base is 8
 ......to base is 2
 .........value= 10 res = 1000
 .........value= 27 res = 10111
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 11
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 3 res = 11
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 95 res = 101
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 10 res = 1000
 .........value= 27 res = 10111
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 11
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 101
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 11
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 8
 .........value= 10 res = 10
 .........value= 27 res = 27
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 3 res = 3
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 95 res = 5
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 10 res = 10
 .........value= 27 res = 27
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 3
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 5
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 10
 .........value= 10 res = 8
 .........value= 27 res = 23
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 3 res = 3
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 95 res = 5
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 10 res = 8
 .........value= 27 res = 23
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 3
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 5
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 16
 .........value= 10 res = 8
 .........value= 27 res = 17
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 3 res = 3
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 95 res = 5
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 10 res = 8
 .........value= 27 res = 17
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 3
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 5
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 36
 .........value= 10 res = 8
 .........value= 27 res = n
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 3 res = 3
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 95 res = 5
+E........exc= Exception: Invalid characters passed for attempted conversion
 .........value= 10 res = 8
 .........value= 27 res = n
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 39 res = 3
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 5
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion

 ...from base is 10
 ......to base is 2
@@ -283,12 +157,8 @@
 .........value= 10 res = 1010
 .........value= 27 res = 11011
 .........value= 39 res = 100111
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 101
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 11
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 8
 .........value= 10 res = 12
 .........value= 27 res = 33
@@ -298,12 +168,8 @@
 .........value= 10 res = 12
 .........value= 27 res = 33
 .........value= 39 res = 47
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 5
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 10
 .........value= 10 res = 10
 .........value= 27 res = 27
@@ -313,12 +179,8 @@
 .........value= 10 res = 10
 .........value= 27 res = 27
 .........value= 39 res = 39
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 5
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 16
 .........value= 10 res = a
 .........value= 27 res = 1b
@@ -328,12 +190,8 @@
 .........value= 10 res = a
 .........value= 27 res = 1b
 .........value= 39 res = 27
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 5
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 36
 .........value= 10 res = a
 .........value= 27 res = r
@@ -343,12 +201,8 @@
 .........value= 10 res = a
 .........value= 27 res = r
 .........value= 39 res = 13
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 5F res = 5
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
+E........exc= Exception: Invalid characters passed for attempted conversion

 ...from base is 16
 ......to base is 2
@@ -361,9 +215,7 @@
 .........value= 27 res = 100111
 .........value= 39 res = 111001
 .........value= 5F res = 1011111
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 11
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 8
 .........value= 10 res = 20
 .........value= 27 res = 47
@@ -374,9 +226,7 @@
 .........value= 27 res = 47
 .........value= 39 res = 71
 .........value= 5F res = 137
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 10
 .........value= 10 res = 16
 .........value= 27 res = 39
@@ -387,9 +237,7 @@
 .........value= 27 res = 39
 .........value= 39 res = 57
 .........value= 5F res = 95
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 16
 .........value= 10 res = 10
 .........value= 27 res = 27
@@ -400,9 +248,7 @@
 .........value= 27 res = 27
 .........value= 39 res = 39
 .........value= 5F res = 5f
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion
 ......to base is 36
 .........value= 10 res = g
 .........value= 27 res = 13
@@ -413,9 +259,7 @@
 .........value= 27 res = 13
 .........value= 39 res = 1l
 .........value= 5F res = 2n
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-.........value= 3XYZ res = 3
+E........exc= Exception: Invalid characters passed for attempted conversion

 ...from base is 36
 ......to base is 2
diff --git a/ext/standard/tests/math/base_convert_improvements.phpt b/ext/standard/tests/math/base_convert_improvements.phpt
index eccf98853cf..e49a1836aca 100644
--- a/ext/standard/tests/math/base_convert_improvements.phpt
+++ b/ext/standard/tests/math/base_convert_improvements.phpt
@@ -12,15 +12,44 @@
 echo base_convert("0o7" , 8, 10) . "\n";
 echo base_convert("0b1010" , 2, 10) . "\n";

-echo "=======================================";
+echo "=======================================\n";

 // These should fail
-echo base_convert('fg', 16, 10);
-echo base_convert('f 0xff ', 16, 10);
-echo base_convert('1xff ', 16, 10);
-echo base_convert(chr(0), 16, 10);
-echo base_convert("0o7" , 9, 10);
-echo base_convert("0 0" , 9, 10) . "\n";
+try {
+    echo base_convert('fg', 16, 10);
+} catch (Exception $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+try {
+    echo base_convert('f 0xff ', 16, 10);
+} catch (Exception $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+try {
+    echo base_convert('1xff ', 16, 10);
+} catch (Exception $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+try {
+    echo base_convert(chr(0), 16, 10);
+} catch (Exception $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+try {
+    echo base_convert("0o7" , 9, 10);
+} catch (Exception $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
+
+try {
+    echo base_convert("0 0" , 9, 10) . "\n";
+} catch (Exception $e) {
+    echo $e::class, ': ', $e->getMessage(), "\n";
+}
 ?>
 --EXPECTF--
 255
@@ -33,15 +62,9 @@
 7
 10
 =======================================
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-15
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-61695
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-511
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-0
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-7
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-0
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
diff --git a/ext/standard/tests/math/base_convert_variation1.phpt b/ext/standard/tests/math/base_convert_variation1.phpt
index f4b00e9293d..bcc18bfa2c0 100644
--- a/ext/standard/tests/math/base_convert_variation1.phpt
+++ b/ext/standard/tests/math/base_convert_variation1.phpt
@@ -74,37 +74,25 @@
 string(2) "14"

 -- Iteration 4 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-string(2) "14"
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 5 --
 string(11) "17777777777"

 -- Iteration 6 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-string(3) "151"
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 7 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-string(3) "151"
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 8 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-string(7) "4553207"
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 9 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-string(7) "4553207"
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 10 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-string(1) "5"
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 11 --
 string(1) "1"
@@ -128,19 +116,13 @@
 TypeError: base_convert(): Argument #1 ($num) must be of type string, array given

 -- Iteration 18 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-string(1) "0"
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 19 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-string(1) "0"
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 20 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-string(1) "0"
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 21 --
 TypeError: base_convert(): Argument #1 ($num) must be of type string, resource given
diff --git a/ext/standard/tests/math/bindec_basic.phpt b/ext/standard/tests/math/bindec_basic.phpt
index d1197ed1645..47c6453dec5 100644
--- a/ext/standard/tests/math/bindec_basic.phpt
+++ b/ext/standard/tests/math/bindec_basic.phpt
@@ -29,50 +29,32 @@
                 );

 for ($i = 0; $i < count($values); $i++) {
-    $res = bindec($values[$i]);
-    var_dump($res);
+    try {
+        $res = bindec($values[$i]);
+        var_dump($res);
+    } catch (Throwable $e) {
+        echo $e::class, ': ', $e->getMessage() . "\n";
+    }
 }
 ?>
 --EXPECTF--
 int(455)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(32766)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(5)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(129)
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
 int(455)
 int(224)
 int(2147483647)

 Notice: Input number is larger than PHP_INT_MAX, precision has been lost in conversion in %s on line %d
 float(2147483648)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(129)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(13)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(13)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(26)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(6)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
 int(1)
 int(0)
diff --git a/ext/standard/tests/math/bindec_basic_64bit.phpt b/ext/standard/tests/math/bindec_basic_64bit.phpt
index 8fece221c0e..7bbab6f85ff 100644
--- a/ext/standard/tests/math/bindec_basic_64bit.phpt
+++ b/ext/standard/tests/math/bindec_basic_64bit.phpt
@@ -29,48 +29,30 @@
                 );

 for ($i = 0; $i < count($values); $i++) {
-    $res = bindec($values[$i]);
-    var_dump($res);
+    try {
+        $res = bindec($values[$i]);
+        var_dump($res);
+    } catch (Throwable $e) {
+        echo $e::class, ': ', $e->getMessage() . "\n";
+    }
 }
 ?>
---EXPECTF--
+--EXPECT--
 int(455)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(32766)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(5)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(129)
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
 int(455)
 int(224)
 int(2147483647)
 int(2147483648)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(129)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(13)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(13)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(26)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(6)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
 int(1)
 int(0)
diff --git a/ext/standard/tests/math/bindec_variation1.phpt b/ext/standard/tests/math/bindec_variation1.phpt
index 420ceeed7a6..1ce32f06653 100644
--- a/ext/standard/tests/math/bindec_variation1.phpt
+++ b/ext/standard/tests/math/bindec_variation1.phpt
@@ -57,8 +57,8 @@
     echo "\n-- Iteration $iterator --\n";
     try {
         var_dump(bindec($input));
-    } catch (TypeError $e) {
-        echo $e->getMessage(), "\n";
+    } catch (Throwable $e) {
+        echo $e::class, ': ', $e->getMessage() . "\n";
     }
     $iterator++;
 };
@@ -74,39 +74,25 @@
 int(1)

 -- Iteration 3 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(1)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 4 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 5 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(2)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 6 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(2)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 7 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(8)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 8 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(1)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 9 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 10 --
 int(1)
@@ -127,22 +113,16 @@
 int(0)

 -- Iteration 16 --
-bindec(): Argument #1 ($binary_string) must be of type string, array given
+TypeError: bindec(): Argument #1 ($binary_string) must be of type string, array given

 -- Iteration 17 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 18 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 19 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 20 --
-bindec(): Argument #1 ($binary_string) must be of type string, resource given
+TypeError: bindec(): Argument #1 ($binary_string) must be of type string, resource given
diff --git a/ext/standard/tests/math/bindec_variation1_64bit.phpt b/ext/standard/tests/math/bindec_variation1_64bit.phpt
index 25f2ec9c7db..746cc12503e 100644
--- a/ext/standard/tests/math/bindec_variation1_64bit.phpt
+++ b/ext/standard/tests/math/bindec_variation1_64bit.phpt
@@ -74,39 +74,25 @@
 int(1)

 -- Iteration 3 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(1)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 4 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 5 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(2)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 6 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(2)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 7 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(8)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 8 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(1)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 9 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 10 --
 int(1)
@@ -130,19 +116,13 @@
 TypeError: bindec(): Argument #1 ($binary_string) must be of type string, array given

 -- Iteration 17 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 18 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 19 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 20 --
 TypeError: bindec(): Argument #1 ($binary_string) must be of type string, resource given
diff --git a/ext/standard/tests/math/hexdec.phpt b/ext/standard/tests/math/hexdec.phpt
index 1f8b57d83fd..7bc8c833515 100644
--- a/ext/standard/tests/math/hexdec.phpt
+++ b/ext/standard/tests/math/hexdec.phpt
@@ -7,9 +7,31 @@

 var_dump(hexdec("012345"));
 var_dump(hexdec("12345"));
-var_dump(hexdec("q12345"));
-var_dump(hexdec("12345+?!"));
-var_dump(hexdec("12345q"));
+
+try {
+    var_dump(hexdec("q12345"));
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage() . "\n";
+}
+
+try {
+    var_dump(hexdec("12345+?!"));
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage() . "\n";
+}
+
+try {
+    var_dump(hexdec("12345q"));
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage() . "\n";
+}
+
+try {
+    var_dump(hexdec("11111111111111111z"));
+} catch (Throwable $e) {
+    echo $e::class, ': ', $e->getMessage() . "\n";
+}
+
 var_dump(hexdec("12345678901234567"));
 var_dump(hexdec("17fffffffffffffff"));

@@ -17,15 +39,10 @@
 --EXPECTF--
 int(74565)
 int(74565)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(74565)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(74565)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(74565)
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion

 Notice: Input number is larger than PHP_INT_MAX, precision has been lost in conversion in %s on line %d
 float(2.0988295476557332E+19)
diff --git a/ext/standard/tests/math/hexdec_basic.phpt b/ext/standard/tests/math/hexdec_basic.phpt
index f1fd76778bf..f518b74ad86 100644
--- a/ext/standard/tests/math/hexdec_basic.phpt
+++ b/ext/standard/tests/math/hexdec_basic.phpt
@@ -25,8 +25,12 @@
                 false,
                 );
 for ($i = 0; $i < count($values); $i++) {
-    $res = hexdec($values[$i]);
-    var_dump($res);
+    try {
+        $res = hexdec($values[$i]);
+        var_dump($res);
+    } catch (Throwable $e) {
+        echo $e::class, ': ', $e->getMessage() . "\n";
+    }
 }
 ?>
 --EXPECTF--
@@ -44,14 +48,10 @@

 Notice: Input number is larger than PHP_INT_MAX, precision has been lost in conversion in %s on line %d
 float(2147483648)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(1194684)
+Exception: Invalid characters passed for attempted conversion
 int(3215381)
 int(3215381)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(3215379)
+Exception: Invalid characters passed for attempted conversion
 int(51446064)
 int(18279)
 int(70199)
diff --git a/ext/standard/tests/math/hexdec_basic_64bit.phpt b/ext/standard/tests/math/hexdec_basic_64bit.phpt
index fd6d53b6019..e011bce1c2a 100644
--- a/ext/standard/tests/math/hexdec_basic_64bit.phpt
+++ b/ext/standard/tests/math/hexdec_basic_64bit.phpt
@@ -29,7 +29,11 @@

 foreach($values as $value) {
     echo "\n-- hexdec $value --\n";
-    var_dump(hexdec($value));
+    try {
+        var_dump(hexdec($value));
+    } catch (Throwable $e) {
+        echo $e::class, ': ', $e->getMessage() . "\n";
+    }
 };

 ?>
@@ -61,9 +65,7 @@
 int(2147483648)

 -- hexdec 0x123XYZABC --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(1194684)
+Exception: Invalid characters passed for attempted conversion

 -- hexdec 311015 --
 int(3215381)
@@ -72,9 +74,7 @@
 int(3215381)

 -- hexdec 31101.3 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(3215379)
+Exception: Invalid characters passed for attempted conversion

 -- hexdec 3110130 --
 int(51446064)
diff --git a/ext/standard/tests/math/hexdec_variation1.phpt b/ext/standard/tests/math/hexdec_variation1.phpt
index cf0d4e81411..da22d403a18 100644
--- a/ext/standard/tests/math/hexdec_variation1.phpt
+++ b/ext/standard/tests/math/hexdec_variation1.phpt
@@ -61,8 +61,8 @@
     echo "\n-- Iteration $iterator --\n";
     try {
         var_dump(hexdec($input));
-    } catch (TypeError $e) {
-        echo $e->getMessage(), "\n";
+    } catch (Throwable $e) {
+        echo $e::class, ': ', $e->getMessage() . "\n";
     }
     $iterator++;
 };
@@ -81,9 +81,7 @@
 int(74565)

 -- Iteration 4 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(9029)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 5 --

@@ -96,14 +94,10 @@
 float(285960729238)

 -- Iteration 7 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(261)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 8 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(261)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 9 --

@@ -111,16 +105,10 @@
 float(20015998341120)

 -- Iteration 10 --
-
-Notice: Input number is larger than PHP_INT_MAX, precision has been lost in conversion in %s on line %d
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-float(1250999896553)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 11 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(5)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 12 --
 int(1)
@@ -141,22 +129,16 @@
 int(0)

 -- Iteration 18 --
-hexdec(): Argument #1 ($hex_string) must be of type string, array given
+TypeError: hexdec(): Argument #1 ($hex_string) must be of type string, array given

 -- Iteration 19 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(2748)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 20 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(2748)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 21 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(2748)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 22 --
-hexdec(): Argument #1 ($hex_string) must be of type string, resource given
+TypeError: hexdec(): Argument #1 ($hex_string) must be of type string, resource given
diff --git a/ext/standard/tests/math/hexdec_variation1_64bit.phpt b/ext/standard/tests/math/hexdec_variation1_64bit.phpt
index c4c2a716d3f..70d89ba69eb 100644
--- a/ext/standard/tests/math/hexdec_variation1_64bit.phpt
+++ b/ext/standard/tests/math/hexdec_variation1_64bit.phpt
@@ -81,9 +81,7 @@
 int(74565)

 -- Iteration 4 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(9029)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 5 --
 int(285960729237)
@@ -92,27 +90,19 @@
 int(285960729238)

 -- Iteration 7 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(261)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 8 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(261)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 9 --
 int(20015998341120)

 -- Iteration 10 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(1250999896553)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 11 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(5)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 12 --
 int(1)
@@ -136,19 +126,13 @@
 TypeError: hexdec(): Argument #1 ($hex_string) must be of type string, array given

 -- Iteration 19 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(2748)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 20 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(2748)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 21 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(2748)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 22 --
 TypeError: hexdec(): Argument #1 ($hex_string) must be of type string, resource given
diff --git a/ext/standard/tests/math/octdec_basic.phpt b/ext/standard/tests/math/octdec_basic.phpt
index 935cb23e1d3..e2414e7f509 100644
--- a/ext/standard/tests/math/octdec_basic.phpt
+++ b/ext/standard/tests/math/octdec_basic.phpt
@@ -25,23 +25,20 @@
                 );

 for ($i = 0; $i < count($values); $i++) {
-    $res = octdec($values[$i]);
-    var_dump($res);
+    try {
+        $res = octdec($values[$i]);
+        var_dump($res);
+    } catch (Throwable $e) {
+        echo $e::class, ': ', $e->getMessage() . "\n";
+    }
 }
 ?>
 --EXPECTF--
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(14489)
+Exception: Invalid characters passed for attempted conversion
 int(253)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(36947879)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(4618484)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(4104)
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
 int(5349)
 int(342391)
 int(375)
@@ -49,13 +46,9 @@

 Notice: Input number is larger than PHP_INT_MAX, precision has been lost in conversion in %s on line %d
 float(2147483648)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(668)
+Exception: Invalid characters passed for attempted conversion
 int(5349)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(102923)
+Exception: Invalid characters passed for attempted conversion
 int(823384)
 int(1)
 int(0)
diff --git a/ext/standard/tests/math/octdec_basic_64bit.phpt b/ext/standard/tests/math/octdec_basic_64bit.phpt
index 4051d9be632..886cc317fa5 100644
--- a/ext/standard/tests/math/octdec_basic_64bit.phpt
+++ b/ext/standard/tests/math/octdec_basic_64bit.phpt
@@ -28,37 +28,29 @@
                 );

 for ($i = 0; $i < count($values); $i++) {
-    $res = octdec($values[$i]);
-    var_dump($res);
+    try {
+        $res = octdec($values[$i]);
+        var_dump($res);
+    } catch (Throwable $e) {
+        echo $e::class, ': ', $e->getMessage() . "\n";
+    }
 }
 ?>
---EXPECTF--
+--EXPECT--
 *** Testing octdec() : basic functionality ***
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(14489)
+Exception: Invalid characters passed for attempted conversion
 int(253)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(36947879)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(4618484)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(4104)
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
+Exception: Invalid characters passed for attempted conversion
 int(5349)
 int(342391)
 int(375)
 int(2147483647)
 int(2147483648)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(668)
+Exception: Invalid characters passed for attempted conversion
 int(5349)
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(102923)
+Exception: Invalid characters passed for attempted conversion
 int(823384)
 int(1)
 int(0)
diff --git a/ext/standard/tests/math/octdec_variation1.phpt b/ext/standard/tests/math/octdec_variation1.phpt
index 214875b7638..d3a8a80093a 100644
--- a/ext/standard/tests/math/octdec_variation1.phpt
+++ b/ext/standard/tests/math/octdec_variation1.phpt
@@ -78,44 +78,28 @@
 int(5349)

 -- Iteration 4 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(1253)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 5 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(1134037)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 6 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(1134038)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 7 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(69)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 8 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(69)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 9 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(175304192)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 10 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(342391)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 11 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(5)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 12 --
 int(1)
@@ -139,19 +123,13 @@
 TypeError: octdec(): Argument #1 ($octal_string) must be of type string, array given

 -- Iteration 19 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 20 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 21 --
-
-Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
-int(0)
+Exception: Invalid characters passed for attempted conversion

 -- Iteration 22 --
 TypeError: octdec(): Argument #1 ($octal_string) must be of type string, resource given