#1 Requst handling 0 and ''


If you perform if(Request::getParameter(x)) and it is
either and '' or 0 it will return as false and the if
will fail.


  • Brian Fioca

    Brian Fioca - 2006-01-26

    Logged In: YES

    This is an interesting bug because it is related to the way
    PHP handles true and false. In PHP null, false, '', and 0
    are all equivalent.

    The easiest way around this is to never rely on implicit
    true or false evaluation. For example, always write code
    like if (request::getParameter(x) !== null) - in PHP === and
    !=== are extra explicit tests that compare for the literal
    evaluation. if (null === 0) will return false, for example.

    It is generally good practice to be as explicit as possible
    because it makes your code easier to read, however I agree
    this is rather confusing, and maybe we should look into
    using explicit === or !=== in the Request object.

  • Brian Fioca

    Brian Fioca - 2006-01-26
    • labels: --> WASP Framework Core
    • status: open --> open-postponed
  • Brian Fioca

    Brian Fioca - 2006-01-26
    • assigned_to: nobody --> bfioca

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks