#50809 [NEW]: empty(), isset() not helpful - need better alternative
From: seanr at webolutionary dot com
Operating system: all
PHP version: 5.3.2RC1
PHP Bug Type: Feature/Change Request
Bug description: empty(), isset() not helpful - need better alternative
Description:
------------
If the value is a string of "0", than it's not a true zero right? The
behavior of empty() in this case is utterly absurd. If you can't fix
empty, there needs to be a new function to provide a better way to
test on this than writing our own special functions to work around a
PHP bug.
$a = 0;
$b = '';
$b = '0'
empty($a) returns true (correctly, but not helpfully)
empty($b) returns true (correctly)
empty($a) returns true (incorrectly, since it actually does have a
value)
Of course, isset() returns true for all three (correctly, but not
helpfully). This means there's no way to find out that $a and $c have
values I can use and $b doesn't without writing my own special
function or if statement. EXTREMELY frustrating.
--
Edit bug report at http://bugs.php.net/?id=50809&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50809&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50809&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50809&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50809&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50809&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50809&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50809&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50809&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50809&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50809&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50809&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50809&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50809&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50809&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50809&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50809&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50809&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50809&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50809&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50809&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50809&r=mysqlcfg
Thread (4 messages)
- seanr at webolutionary dot com