Browse Source

fixed int and float check

master
Robin Thoni 9 years ago
parent
commit
b58ed4ace8
1 changed files with 7 additions and 2 deletions
  1. 7
    2
      utils.php

+ 7
- 2
utils.php View File

@@ -38,9 +38,14 @@ function get_get($key, $is_error = true)
38 38
   return get_param($_GET, $key, $is_error);
39 39
 }
40 40
 
41
-function check_float($f)
41
+function check_float($f, $def = null)
42 42
 {
43
-  return ($f == (string)(float)$f) ? $f : null;
43
+  return ($f == (string)(float)$f) ? $f : $def;
44
+}
45
+
46
+function check_int($i, $def = null)
47
+{
48
+  return is_numeric($i) ? $i : $def;
44 49
 }
45 50
 
46 51
 function check_table_field($header, $table, $field)

Loading…
Cancel
Save