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