xref: /PHP-8.3/ext/filter/tests/bug51368.phpt (revision 74859783)
1--TEST--
2FR #51368 (php_filter_float does not allow custom thousand separators)
3--EXTENSIONS--
4filter
5--FILE--
6<?php
7$options = ['flags' => FILTER_FLAG_ALLOW_THOUSAND, 'options' => ['thousand' => ' ']];
8var_dump(
9    filter_var('1 000', FILTER_VALIDATE_FLOAT, $options),
10    filter_var('1 234.567', FILTER_VALIDATE_FLOAT, $options)
11);
12$options = ['flags' => FILTER_FLAG_ALLOW_THOUSAND, 'options' => ['thousand' => '']];
13
14try {
15    filter_var('12345', FILTER_VALIDATE_FLOAT, $options);
16} catch (ValueError $exception) {
17    echo $exception->getMessage() . "\n";
18}
19
20?>
21--EXPECT--
22float(1000)
23float(1234.567)
24filter_var(): "thousand" option cannot be empty
25