Re: PHP 4.0 Bug #6956 Updated: empty( "0" ) returns true
| From: | Matthew Hagerty | Date: | Fri, 29 Sep 2000 17:39:42 +0000 |
| Subject: | Re: PHP 4.0 Bug #6956 Updated: empty( "0" ) returns true | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-33898@lists.php.net to get a copy of this message | ||
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@phpopentracker.de
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@phpopentracker.de
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@lists.php.net
For additional commands, e-mail: php-dev-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net