public function index()
{
//當前是否爲關聯查詢
$this->relationSearch = false;
//設置過濾方法
$this->request->filter(['strip_tags', 'trim']);
}
$this->request->filter(['strip_tags', 'trim']);
如上,可以設置對單個方法 提交過來參數的設置。
- trim: 去掉兩段的空格
- strip_tags 於 htmlspecialchars 都是去掉html格式
<?php
$a = 'hello <b>zq!</b>';
echo htmlspecialchars($a); //hello <b>zq!</b>
echo strip_tags($a); //hello zq!
?>
如果想全局設置,可以根據業務需求,在相對應的層級中的 config.php中設置
// 默認全局過濾方法 用逗號分隔多個
'default_filter' => '',