Skip to content

Commit f3b4675

Browse files
committed
use regex instead of is_numeric
1 parent 211d647 commit f3b4675

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

resources/lib/utils.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ function getHyperlink($text, ...$url_components)
8989
*/
9090
function str2int(string $x, ...$args): int
9191
{
92-
if (is_numeric($x)) {
92+
if (preg_match("/^[0-9]+$/", $x)) {
9393
return intval($x, ...$args);
9494
} else {
95-
throw new ValueError("not numeric: $x");
95+
throw new ValueError("not digits: $x");
9696
}
9797
}

0 commit comments

Comments
 (0)