function protect($var) { return htmlspecialchars(((mb_detect_encoding($var)=='UTF-8')?$var:utf8_encode($var)),ENT_QUOTES); }