intval(0) == ????

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Bedford

    #1

    intval(0) == ????

    I can't figure out what does return intaval(0).

    I've this code in a function:

    $theValue = ($theValue != "" ? intval($theValu e) : NULL);

    when I do test this
    if $theValue = = NULL then
    fails if the value passed is '0' (an edit type on a form).

    what's wrong

    Bob



  • Erwin Moller

    #2
    Re: intval(0) == ????

    Bob Bedford wrote:
    [color=blue]
    > I can't figure out what does return intaval(0).
    >
    > I've this code in a function:
    >
    > $theValue = ($theValue != "" ? intval($theValu e) : NULL);
    >
    > when I do test this
    > if $theValue = = NULL then
    > fails if the value passed is '0' (an edit type on a form).
    >
    > what's wrong
    >
    > Bob[/color]

    Hi Bob,

    I think that you mean: "NULL" instead of NULL.
    NULL is NOT a PHP predifined value.
    When using in a (dynamically created) query, you should use "NULL" as a
    string.

    As in:

    $SQL = "INSERT INTO myTable (userid,age) VALUES ($userid,$theVa lue)";

    Regards,
    Erwin Moller

    Comment

    • Janwillem Borleffs

      #3
      Re: intval(0) == ????

      Bob Bedford wrote:[color=blue]
      > I can't figure out what does return intaval(0).
      >
      > I've this code in a function:
      >
      > $theValue = ($theValue != "" ? intval($theValu e) : NULL);
      >
      > when I do test this if $theValue = = NULL then
      > fails if the value passed is '0' (an edit type on a form).
      >
      > what's wrong
      >[/color]

      Use type comparison:

      $theValue === NULL



      JW


      Comment

      • Andy Hassall

        #4
        Re: intval(0) == ????

        On Wed, 02 Feb 2005 16:42:35 +0100, Erwin Moller
        <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> wrote:
        [color=blue]
        >I think that you mean: "NULL" instead of NULL.
        >NULL is NOT a PHP predifined value.[/color]

        Yes it is.



        --
        Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
        <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

        Comment

        • Erwin Moller

          #5
          Re: intval(0) == ????

          Andy Hassall wrote:
          [color=blue]
          > On Wed, 02 Feb 2005 16:42:35 +0100, Erwin Moller
          > <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> wrote:
          >[color=green]
          >>I think that you mean: "NULL" instead of NULL.
          >>NULL is NOT a PHP predifined value.[/color]
          >
          > Yes it is.
          >
          >[/color]
          http://uk.php.net/manual/en/language...es.null.syntax[color=blue]
          >[/color]

          Yes, you are right.
          SOrry for the misinformation!

          Regards,
          Erwin Moller

          Comment

          Working...