众所周知, CodeIgniter 拥有大量的文档,但是有很多不错的代码没有出现在文档中,这里就有三个不错的小技巧,可以让你的开发变得更轻松。 返回所有POST项目并且进行XSS过滤,我们可以通过第二个boolean参数来设定,例如: $fields = $this - input - post (
众所周知,
允许你对所有的$_POST项进行操作,无须一条条的来。
使用表单验证内部读和使用$ _POST数组,因此简单地写:
虽然有点问题,完美的工作。还记得,表单验证库是……只是一个library。继续借其功能为您要去的地方,你可以在system/libraries目录中找到:
你还可以处理表单数据传递给你的回调并返回它。如果你的回调返回以外的任何一个布尔值TRUE / FALSE假设数据是你的新处理表单数据。
换句话说,写一个回调如:
will, instead of simply passing or failing a test, allow you to fully manipulate the data and pass it back to your controller function. (As a real-life example, on a recent project I needed to hit the database to check if a given airport code was valid before insert, but also wanted to insert some denormalized data about that airport at the same time. Since I was hitting the database anyway, I passed back the whole row of info I wanted & processed it for the insert.)
So...read those bits of fine print! There are some gems in there.
希望能够帮助到您.
(责任编辑:CIT信息网)