Req #49942 [Com]: SimpleXML can't change value of reference

From: Date: Tue, 23 Nov 2021 18:03:48 +0000
Subject: Req #49942 [Com]: SimpleXML can't change value of reference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237951@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=49942&edit=1 ID: 49942 Comment by: janeesharmaa at gmail dot com Reported by: gf at glbasic dot com Summary: SimpleXML can't change value of reference Status: Open Type: Feature/Change Request Package: SimpleXML related Operating System: Debian PHP Version: 5.2.11 Block user comment: N Private report: N New Comment: The professionally well-trained and prepared Mumbai escort girls would never fail to attend their clients’ calls. https://www.classycallgirls.com/ https://www.classycallgirls.com/mumbai-call-girls.html Previous Comments: ------------------------------------------------------------------------ [2009-10-21 12:29:30] gf at glbasic dot com Description: ------------ If you have a reference to an SimpleXML subtree item, you cannot change the value of that. Reproduce code: --------------- <?php $xml = new SimpleXMLElement("<?xml version='1.0'?>\n" ."<chunk>\n" ."<item id='1'>one</item>\n" ."<item id='2'>two</item>\n" ."</chunk>\n" ); function test(& $xentry) { $xentry['id'] = 22; // set id=2 to id=22, works fine $xentry = 'TWENTYTWO'; // !!! this line is ignored !!! } $xml->item[0] = 'ELEVEN'; // works $xml->item[0]['id']=11; // works echo str_replace("\n", "<br>", htmlspecialchars($xml->asXML()))."<br>"; // OK, fine // try the same with a reference -> does not work test($xml->item[1]); echo "<h3>After replacement:</h2>"; echo str_replace("\n", "<br>", htmlspecialchars($xml->asXML())); // error - $xentry is not an object ?> Expected result: ---------------- ... <item id="2">two</item> After replacement: ... <item id="22">TWENTYTWO</item> Actual result: -------------- ... <item id="2">two</item> After replacement: ... <item id="22">two</item> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=49942&edit=1

« previous php.bugs (#237951) next »