1--TEST-- 2filter_var() and FLOAT 3--SKIPIF-- 4<?php if (!extension_loaded("filter")) die("skip"); ?> 5--INI-- 6precision=14 7--FILE-- 8<?php 9 10$floats = array( 11'1.234 ', 12' 1.234', 13'1.234' , 14'1.2e3', 15'7E3', 16'7E3 ', 17' 7E3 ', 18' 7E-3 ' 19); 20 21foreach ($floats as $float) { 22 $out = filter_var($float, FILTER_VALIDATE_FLOAT); 23 var_dump($out); 24} 25 26$floats = array( 27'1.234 ' => ',', 28'1,234' => ',', 29' 1.234' => '.', 30'1.234' => '..', 31'1.2e3' => ',' 32); 33 34echo "\ncustom decimal:\n"; 35foreach ($floats as $float => $dec) { 36 $out = filter_var($float, FILTER_VALIDATE_FLOAT, array("options"=>array('decimal' => $dec))); 37 var_dump($out); 38} 39 40?> 41--EXPECTF-- 42float(1.234) 43float(1.234) 44float(1.234) 45float(1200) 46float(7000) 47float(7000) 48float(7000) 49float(0.007) 50 51custom decimal: 52bool(false) 53float(1.234) 54float(1.234) 55 56Warning: filter_var(): decimal separator must be one char in %s on line %d 57bool(false) 58bool(false) 59