Connecting Tech Pros Worldwide Help | Site Map

Distinguishing between an empty string and "0"

 
LinkBack Thread Tools Search this Thread
  #1  
Old May 11th, 2006, 09:15 PM
laredotornado@zipmail.com
Guest
 
Posts: n/a
Default 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


  #2  
Old May 11th, 2006, 09:35 PM
Rik
Guest
 
Posts: n/a
Default Re: Distinguishing between an empty string and "0"

laredotornado@zipmail.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']===''

http://nl2.php.net/manual/en/languag...comparison.php

Grtz,
--
Rik Wasmus


  #3  
Old May 12th, 2006, 12:35 AM
Toby Inkster
Guest
 
Posts: n/a
Default Re: Distinguishing between an empty string and "0"

laredotornado@zipmail.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($_REQUEST['myvar']))
{
// not empty
}

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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.