note 40044 added to ref.simplexml

From: Date: Thu, 19 Feb 2004 20:04:21 +0000
Subject: note 40044 added to ref.simplexml
Groups: php.notes 
Request: Send a blank email to php-notes+get-65423@lists.php.net to get a copy of this message
Simplexml's simplicity can be deceptive. Simplexml elements behave either as objects or strings, depending on the context in which they're used (through overloading of the __toString() method, I assume). Statements implying conversion to string treat them as strings, while assignment operations treat them as objects. This can lead to unexpected behavior if, for example, you are trying to compare the values of two Simplexml elements. The expected syntax will not work. To force conversion to strings, just place whatever Simplexml element you're using inside double quotes. For example: $s = simplexml_load_string('<foo>43</foo> <bar>43</bar>'); // Evaluates to false ($s->foo == $s->bar); // Evaluates to true ("$s->foo" == "$s->bar"); This is accurate as of PHP 5 Beta 4. ---- Manual Page -- http://www.php.net/manual/en/ref.simplexml.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40044 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40044&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40044&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#65423) next »