formCast使用PHP转换表单数据处理
使用PHP转换表单要求PHP 5.5+,只需将formCast.php复制到您的工作目录中,不要忘记包含它:
require_once(MY_PATH . '/cast.php');
如何使用它:
$_GET['name'] = 'my name is drop database';
$_GET['password'] = 'my@@!$#$SDFpassword';
$_GET['age'] = 151;
$_GET['colors'] = [1, 2, 3, 'koko'];
然后,创建一个新的 Forms Layer 实例来处理这些表单数据:
$vars = (new FormsLayer($_GET, array('name' => 'string', 'password' => 'password', 'age' => 'integer', 'colors' => 'array')));
formCast 会根据指定的字段类型对表单数据进行转换和验证。
下载地址
用户评论