Distinguishing between an empty string and "0"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laredotornado@zipmail.com

    Distinguishing between an empty string and "0"

    Hi,

    If I have a $_REQUEST variable that contains either the value "" or
    "0", the empty($_REQUEST['myvar']) call returns the same thing -- 1.
    How can I distinguish between these values without causing any errors
    or warnings (notices)?

    I'm using PHP 4. Thanks for the help, - Dave

  • Rik

    #2
    Re: Distinguishing between an empty string and "0&quot ;

    laredotornado@z ipmail.com wrote:[color=blue]
    > Hi,
    >
    > If I have a $_REQUEST variable that contains either the value "" or
    > "0", the empty($_REQUEST['myvar']) call returns the same thing -- 1.
    > How can I distinguish between these values without causing any errors
    > or warnings (notices)?
    >
    > I'm using PHP 4. Thanks for the help, - Dave[/color]

    $_REQUEST['myvar']===0
    or
    $_REQUEST['myvar']===''



    Grtz,
    --
    Rik Wasmus


    Comment

    • Toby Inkster

      #3
      Re: Distinguishing between an empty string and "0&quot ;

      laredotornado@z ipmail.com wrote:
      [color=blue]
      > If I have a $_REQUEST variable that contains either the value "" or
      > "0", the empty($_REQUEST['myvar']) call returns the same thing -- 1.[/color]

      if (strlen($_REQUE ST['myvar']))
      {
      // not empty
      }

      --
      Toby A Inkster BSc (Hons) ARCS
      Contact Me ~ http://tobyinkster.co.uk/contact

      Comment

      Working...