php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36210 different result of count in 5.1.2
Submitted: 2006-01-30 14:37 UTC Modified: 2006-01-30 15:39 UTC
From: urs dot huerlimann at abf dot ch Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5.1.2 OS: Win2003Server
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: urs dot huerlimann at abf dot ch
New email:
PHP Version: OS:

 

 [2006-01-30 14:37 UTC] urs dot huerlimann at abf dot ch
Description:
------------
count of an xml-object returns different result in 5.1.2 and 5.0.4:

is there any bugfix in 5.1.2 that causes this behavior?

[5.0.4] the structure looks like:
object(SimpleXMLElement)#15 (6) {
  ["SaveMode"]=>
  string(6) "Insert"
  ["ManCd"]=>
  string(3) "BAG"
  ["RegNr"]=>
  string(47) "5_0x2E460x2E46_90_0x2E460x2E46_07_0x2E460x2E46_"
  ["DosNr"]=>
  string(16) "_0x2D450x2D45_43"
  ["Verantw"]=>
  string(6) "BAG070"
  ["Titel"]=>
  string(124) "105228 _0x7C1240x7C124_ WERT_CASNR _0x7C1240x7C124_ WERT_ECNR _0x7C1240x7C124_ WERT_REGISTERNR _0x7C1240x7C124_ WERT_BEZNAME"
}

=====================================================
[5.1.2] similar structure looks like
object(SimpleXMLElement)#18 (6) {
  ["SaveMode"]=>
  string(6) "Insert"
  ["ManCd"]=>
  string(3) "BAG"
  ["RegNr"]=>
  string(47) "5_0x2E460x2E46_90_0x2E460x2E46_33_0x2E460x2E46_"
  ["DosNr"]=>
  string(15) "_0x2D450x2D45_1"
  ["Verantw"]=>
  string(6) "BAG070"
  ["Titel"]=>
  string(146) "3694 _0x7C1240x7C124_ 115_0x2D450x2D45_09_0x2D450x2D45_3 _0x7C1240x7C124_ 204_0x2D450x2D45_064_0x2D450x2D45_2 _0x7C1240x7C124_ chloromethylmercury"
}

Reproduce code:
---------------
SimpleXMLElement has six entries.

$a = new array();
$a[]=$SimpleXMLElement;
(...)
foreach($a as $detail)
{
  echo(count($detail));
}


Expected result:
----------------
twice the same result

Actual result:
--------------
5.0.4::count -> 1
5.1.2::count -> 6

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-30 15:19 UTC] tony2001@php.net
Yes, since 5.1 SimpleXML objects correctly implement count interface.
 [2006-01-30 15:31 UTC] urs dot huerlimann at abf dot ch
maybe something different with "get_object_vars()"
 [2006-01-30 15:34 UTC] urs dot huerlimann at abf dot ch
have not seen your answer, forget my latest comment.
thanks.
 [2006-01-30 15:39 UTC] urs dot huerlimann at abf dot ch
So we have to implement different versions depending on our customers php versions...

;-) thanks for your fast answer.
urs h?rlimann
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 07:01:33 2025 UTC