$myts = MyTextSanitizer::getInstance(); |
$myts -> addSlashes (文字); |
$myts ->censorString(文字); |
//檢查並傳回欲拿到資料使用的變數 |
function clean_var( $var = '' , $title = '' , $filter = '' ) |
{ |
$myts = MyTextSanitizer::getInstance(); |
$var = $myts -> addSlashes ( $_REQUEST [ $var ]); |
if ( empty ( $var )) { |
throw new Exception( "{$title}為必填!" ); |
} |
if ( $filter ) { |
$var = filter_var( $var , $filter ); |
if (! $var ) { |
throw new Exception( "不合法的{$title}" ); |
} |
} |
return $var ; |
} |