douzi4766 2011-02-09 03:43
浏览 10
已采纳

我可以一起使用这些PHP函数吗?

Can I use these PHP functions below:

$user = mysql_escape_string($user);
$user = filter_var($user, FILTER_SANITIZE_STRING);
$user = stripslashes($user);
$user = trim($user);

together like this:

$user = mysql_escape_string(stripslashes(trim(filter_var($user, FILTER_SANITIZE_STRING))));

sorry if this is a stupid question.

  • 写回答

5条回答 默认 最新

  • dpda53918 2011-02-09 04:00
    关注

    var_filter validate or sanitize your var according to a list of predefined filters: FILTER_VALIDATE_EMAIL, FILTER_SANITIZE_EMAIL, FILTER_VALIDATE_URL, FILTER_SANITIZE_URL.

    trim and stripslashes are old school way to sanitize your vars

    mysql_escape_string sanitize your querys for mysql, therefore this function are deprecated, you must use mysql_real_escape_string, the syntax is identical.

    var_filter are most elegant and have many options from trim and stripslashes

    http://www.php.net/manual/en/filter.filters.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?