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
function clear_value($string) {
//Trims white space from the front and back of string
       $string = trim($string);
//Strips tags from string
       $string = strip_tags($string);
//Escapes string
       $string = mysql_real_escape_string($string);
//Returns the string
       return $string;
}
 
/* Example of use
<?
function clear_value($string) {
       $string = trim($string);
       $string = strip_tags($string);
       $string = htmlspecialchars($string);
       return $string;
}
 
$value = $_GET['value'];
$value = clear_value($value);
echo $value;
 
//Value is now trimmed, stripped of any tags, and special characters are converted into proper HTML
*/
 
//Any number of string functions may be added into clear_value().
//With this function, your code becomes a bit cleaner.