-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathdata_types.php
More file actions
57 lines (52 loc) · 932 Bytes
/
data_types.php
File metadata and controls
57 lines (52 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
//convert_to_int()
function convert_to_int($input){
if (settype($input, "int")) {
return $input;
} else {
return 0;
}
}
//convert_to_float()
function convert_to_float($input){
if (settype($input, "float")) {
return $input;
} else {
return 0.0;
}
}
//convert_to_string()
function convert_to_string($input){
if (is_array($input)) {
return implode(", ", $input);;
} elseif (!settype($input, "string")){
return "";
} else {
return $input;
}
}
//convert_to_bool()
function convert_to_bool($input){
if (settype($input, "bool")){
return $input;
} else {
return false;
}
}
//convert_to_array()
function convert_to_array($input){
if (settype($input, "array")) {
return $input;
} else {
return array();
}
}
//convert_to_null()
function convert_to_null($input){
if (!$input || $input === "null"){
return null;
} else {
return $input;
}
}
?>