|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-11-25 21:24 UTC] cataphract@php.net
-Status: Open
+Status: Bogus
[2010-11-25 21:24 UTC] cataphract@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 16:00:01 2025 UTC |
Description: ------------ I use xmlWriter a lot, but I found a quite inconsistent behavior with booleans in xmlWriter. When filling an element/namespace with a boolean : - if the boolean is true, it is automatically casted to an int (1), which is a legal representation of the boolean. - if the boolean is false, no value is given to the element/attribute. I made a little script to reproduce the problem.It runs well in CLI Test script: --------------- <?php xml(true); xml(false); function xml($bool) { $xml = new XmlWriter(); $xml->openMemory(); $xml->setIndent(true); $xml->startElement('root'); $xml->writeAttribute('boolAttr', $bool); $res = $xml->writeElement('myboolean',$bool); $xml->endElement(); echo $xml->flush().PHP_EOL; var_dump($res); } Expected result: ---------------- <root boolAttr="1"> <myboolean>1</myboolean> </root> bool(true) <root boolAttr="0"> <myboolean>0</myboolean> </root> Actual result: -------------- <root boolAttr="1"> <myboolean>1</myboolean> </root> bool(true) <root boolAttr=""> <myboolean></myboolean> </root>