Doc #54923 [NEW]: intval() always return 1 with empty objets
| From: | gwarnants at gmail dot com | Date: | Wed, 25 May 2011 09:36:21 +0000 |
| Subject: | Doc #54923 [NEW]: intval() always return 1 with empty objets | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-6656@lists.php.net to get a copy of this message | ||
From:
Operating system:
PHP version: 5.3.6
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:intval() always return 1 with empty objets
Description:
------------
---
From manual page: http://www.php.net/function.intval#Return
Values
---
I can read in the manual that intval() could return 0 with empty objets or
arrays, and 1 with non-empty objets or arrays.
Obviously, it seems intval() always return 1 with empty objets.
Regards,
Geoffray
Test script:
---------------
$o = new stdClass();
echo 'empty object ='.intval($o)."\n";
$o->foo = 'bar';
echo 'non empty object ='.intval($o)."\n";
$a = array();
echo 'empty array ='.intval($a)."\n";
$a['foo'] = 'bar';
echo 'non empty array ='.intval($a)."\n";
Expected result:
----------------
empty object =0
non empty object =1
empty array =0
non empty array =1
Actual result:
--------------
empty object =1
non empty object =1
empty array =0
non empty array =1
--
Edit bug report at http://bugs.php.net/bug.php?id=54923&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54923&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54923&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54923&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54923&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54923&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54923&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54923&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54923&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54923&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54923&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54923&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54923&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54923&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54923&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54923&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54923&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54923&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54923&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54923&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54923&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54923&r=mysqlcfg