Something
public text v1 · immutablefunction clean($string){
$string = addslashes($string);
# addslashes to prevent SQL injections
$string = strip_tags($string);
# strip any tags
$string = htmlspecialchars($string);
# set any html left over to special characters
$string = trim($string);
# trim the string of any unwanted spaces at the start or end
$string = mysql_escape_string($string);
$string = mysql_real_escape_string($string);
return $string;
# retrun the cleaned string
}