Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33913 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92236 invoked by uid 1010); 10 Dec 2007 21:01:10 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 92220 invoked from network); 10 Dec 2007 21:01:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Dec 2007 21:01:10 -0000 Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:46617] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 81/A8-39150-319AD574 for ; Mon, 10 Dec 2007 16:01:10 -0500 Received: from MBOERGER-ZRH.corp.google.com (161-215.0-85.cust.bluewin.ch [85.0.215.161]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id 8B2181B352C; Mon, 10 Dec 2007 22:00:55 +0100 (CET) Date: Mon, 10 Dec 2007 22:00:25 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <1723341090.20071210220025@marcus-boerger.de> To: Rob Richards CC: "Frank M. Kromann" , internals@lists.php.net, In-Reply-To: <475BDDF1.7040605@ctindustries.net> References: <11970653983080000@9866357972520000.9866341568840000> <475BDDF1.7040605@ctindustries.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP 5.3 bug or changed feature?? From: helly@php.net (Marcus Boerger) Hello Rob, this is intended. The 5.2 solution is just a hack and returns a wrong result in the first place. The hack was however introduced to make development easier. Now with 5.3 we were able to change the API and coudl apply the solution that was first developed in HEAD. marcus Sunday, December 9, 2007, 1:22:09 PM, you wrote: > Hi Frank, > Frank M. Kromann wrote: >> Hello Everyon, >> >> Casting a SimpleXML object to an array gives different results in PHP >> 5.2.5 and PHP 5.3-dev. >> > This is due to the implementation of the get_debug_info handler merged > from HEAD. > The same result happens when calling get_object_vars on a > SimpleXMLElement object. > Marcus, was it intended to only include @attributes with print_r/var_dump? > Rob >> Source: >> >> $xml = simplexml_load_file("sample.xml"); >> >> foreach($xml->column as $column) { >> var_dump($column); >> var_dump((array)$column); >> } >> >> sample.xml >> >> ?xml version="1.0"?> >> >> >> cv >> entsimp >> >> >> pp >> sc >> >> >> >> PHP 5.2 output: >> object(SimpleXMLElement)#4 (2) { >> ["@attributes"]=> >> array(1) { >> ["name"]=> >> string(13) "ENTERTAINMENT" >> } >> ["module"]=> >> array(2) { >> [0]=> >> string(2) "cv" >> [1]=> >> string(7) "entsimp" >> } >> } >> array(2) { >> ["@attributes"]=> >> array(1) { >> ["name"]=> >> string(13) "ENTERTAINMENT" >> } >> ["module"]=> >> array(2) { >> [0]=> >> string(2) "cv" >> [1]=> >> string(7) "entsimp" >> } >> } >> object(SimpleXMLElement)#5 (2) { >> ["@attributes"]=> >> array(1) { >> ["name"]=> >> string(12) "SEAT CONTROL" >> } >> ["module"]=> >> array(2) { >> [0]=> >> string(2) "pp" >> [1]=> >> string(2) "sc" >> } >> } >> array(2) { >> ["@attributes"]=> >> array(1) { >> ["name"]=> >> string(12) "SEAT CONTROL" >> } >> ["module"]=> >> array(2) { >> [0]=> >> string(2) "pp" >> [1]=> >> string(2) "sc" >> } >> } >> >> PHP 5.3 output: >> >> object(SimpleXMLElement)#4 (2) { >> ["@attributes"]=> >> array(1) { >> ["name"]=> >> string(13) "ENTERTAINMENT" >> } >> ["module"]=> >> array(2) { >> [0]=> >> string(2) "cv" >> [1]=> >> string(7) "entsimp" >> } >> } >> array(1) { >> ["module"]=> >> array(2) { >> [0]=> >> string(2) "cv" >> [1]=> >> string(7) "entsimp" >> } >> } >> object(SimpleXMLElement)#5 (2) { >> ["@attributes"]=> >> array(1) { >> ["name"]=> >> string(12) "SEAT CONTROL" >> } >> ["module"]=> >> array(2) { >> [0]=> >> string(2) "pp" >> [1]=> >> string(2) "sc" >> } >> } >> array(1) { >> ["module"]=> >> array(2) { >> [0]=> >> string(2) "pp" >> [1]=> >> string(2) "sc" >> } >> } >> >> Not that the attributes are gone when SimpleXML objects are converted in >> PHP 5.3. Is this a bug or a feature change? >> >> - Frank >> >> Best regards, Marcus