Jump to content

Nicos99

Members
  • Posts

    1
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Nicos99

  1. On 10/11/2019 at 2:04 AM, Ingolme said:

    They could just use !!filter_var() or (bool)filter_var() and they wouldn't need the === false part. This would still not solve the integer zero problem, though.

    I think the correct way is to do the check is this way :

    if (!(filter_var($int, FILTER_VALIDATE_INT) === false)) {
      echo("Integer is valid");
    } else {
      echo("Integer is not valid");
    }

    Because the rule is that `filter_var' return bool(false) only if there is an invalid integer, else return int(the value). And we test "!(fnc === false)" because the `!`operator take precedence over `===` otherwise.

    More over hese is no integer zero problem anymore ;)

    ==> What do you think of that ?

    • Like 1
×
×
  • Create New...