为什么最好使用filter_input()? [英] Why is better to use filter_input()?

查看:155
本文介绍了为什么最好使用filter_input()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该是一个基本的问题,但为什么最好使用这样的:

pre $ pwd = filter_input(INPUT_POST, 'PWD');

而不是:

  $ pwd = $ _POST ['pwd']; PS:我明白,过滤器扩展可以用更多的参数来提供额外的消毒等级。

解决方案

事实并非如此。 $ _ GET $ _ POST $ _ COOKIE $ _ REQUEST 使用默认过滤器。没有附加参数的 filter_input(INPUT_POST,'pwd')也使用默认过滤器。所以没有任何区别。


This should be a elementary question but why is better to use something like this:

$pwd = filter_input(INPUT_POST, 'pwd');

Instead of just:

$pwd = $_POST['pwd'];

PS: I understand that the filter extension can be used with more arguments to provide an additional level of sanitization.

解决方案

It's not. $_GET, $_POST, $_COOKIE and $_REQUEST are filtered with default filter. filter_input(INPUT_POST, 'pwd') without additional parameters also uses the default filter. So there is no difference at all.

这篇关于为什么最好使用filter_input()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆