Re: [PHP-DEV] PHP 4.0 Bug #6956 Updated: empty( "0" ) returns true From: Matthew Hagerty (mhagerty <email protected>)
Date: 09/29/00

The function empty() is really confusing and once I read the docs on it I
realized I was using it for the wrong purpose. I wrote a quick function
that does what I thought empty() was doing. Hope this helps.

/*
  * Determine is a string is *really* empty.
  */
function
blank($sString)
{
         /*
          * Make sure we really got passed a string.
          */
         settype($sString, "string");

         $sTemp = trim($sString);

         if ( strlen($sTemp) <= 0 )
                 return(true);

         return(false);
}

Enjoy,
Matthew

At 04:13 AM 9/30/00 +0000, you wrote:
>ID: 6956
>Updated by: sbergmann
>Reported By: sb <email protected>
>Status: Closed
>Bug Type: Variables related
>Assigned To:
>Comments:
>
> Dear Sebastian,
>
> please read the manual entry on empty().
>
> Yours,
>Sebastian
>
>
>Previous Comments:
>---------------------------------------------------------------------------
>
>[2000-09-29 23:54:57] sb <email protected>
>The following script
>
> <?php
> $str = "0";
> print empty( $str );
> ?>
>
>outputs "true". Is this a bug or a feature?
>
>
>---------------------------------------------------------------------------
>
>
>Full Bug description available at: http://bugs.php.net/?id=6956
>
>
>--
>PHP Development Mailing List <http://www.php.net/>
>To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
>For additional commands, e-mail: php-dev-help <email protected>
>To contact the list administrators, e-mail: php-list-admin <email protected>

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>