php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #29029 Object to integer typecast is incorrect
Submitted: 2004-07-06 14:59 UTC Modified: 2004-09-18 20:57 UTC
From: tomas_matousek at hotmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.0.0RC3 OS: WinXP
Private report: No CVE-ID: None
 [2004-07-06 14:59 UTC] tomas_matousek at hotmail dot com
Description:
------------
No description needed.

Reproduce code:
---------------
var_dump((int) new stdClass());

Expected result:
----------------
0

Actual result:
--------------
object(stdClass)#2 (0) {
}



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-14 15:45 UTC] php at hristov dot com
php -r '$a= (float) new stdClass(); var_dump($a);'

gives float(1)
 [2004-09-10 05:36 UTC] curt@php.net
This behaviour is expected, moving over as a documentation problem.

Casting Objects:
  int      - not able to cast
  dobule   - notice thrown, returns 1.0
  null     - returns null
  bool     - returns 1 
  string   - user __toString() if applicable or 'Object'

ze1_compatibility_mode
casting object
 int/float/bool - 1 or 0 signifying it has properties

 [2004-09-18 20:57 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Apr 27 23:01:28 2025 UTC