Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

filter_has_var vs isset

Guest
Aug 21, 2012 Aug 21, 2012

Copy link to clipboard

Copied

I am using the following to sanitize input prior to validating:

if(filter_has_var(INPUT_POST, "$var")) {

$sanitized = filter_input(INPUT_POST, '$var', FILTER_SANITIZE_STRING);

$_POST['$var'] = trim($sanitized);

Is it preferable to use filter_has_var() to check the input or isset()? Is there a difference and what is it?

Thank you in advance for any help.

TOPICS
Server side applications

Views

924
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 25, 2012 Aug 25, 2012

According to an anonymous note in the PHP documentation, filter_has_var() is slightly faster than isset(). I've no idea if that's accurate, but it hasn't been removed by the PHP documentation team, so it seems legitimate.

Other than that, there's no difference.

Votes

Translate
LEGEND ,
Aug 25, 2012 Aug 25, 2012

Copy link to clipboard

Copied

LATEST

According to an anonymous note in the PHP documentation, filter_has_var() is slightly faster than isset(). I've no idea if that's accurate, but it hasn't been removed by the PHP documentation team, so it seems legitimate.

Other than that, there's no difference.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines