Browse Source

fixed http status line

master
Robin Thoni 10 years ago
parent
commit
def02f6087
1 changed files with 4 additions and 3 deletions
  1. 4
    3
      utils.php

+ 4
- 3
utils.php View File

14
 
14
 
15
 function error($code, $message)
15
 function error($code, $message)
16
 {
16
 {
17
-  header("HTTP/ $code $message");
17
+  http_response_code($code);
18
+  /* header("HTTP/ $code $message"); */
18
   die(json_encode(array("code" => intval($code), "message" => $message)));
19
   die(json_encode(array("code" => intval($code), "message" => $message)));
19
 }
20
 }
20
 
21
 
40
 
41
 
41
 function check_float($f, $def = null)
42
 function check_float($f, $def = null)
42
 {
43
 {
43
-  return ($f == (string)(float)$f) ? $f : $def;
44
+  return is_numeric($f) ? $f : $def;
44
 }
45
 }
45
 
46
 
46
 function check_int($i, $def = null)
47
 function check_int($i, $def = null)
47
 {
48
 {
48
-  return is_numeric($i) ? $i : $def;
49
+  return is_numeric($i) && $i == (int)$i ? $i : $def;
49
 }
50
 }
50
 
51
 
51
 function check_table_field($header, $table, $field)
52
 function check_table_field($header, $table, $field)

Loading…
Cancel
Save