|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-12-12 19:26 UTC] Wes dot example at example dot org
[2020-03-10 11:00 UTC] cmb@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cmb
[2020-03-10 11:00 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 22:00:01 2025 UTC |
Description: ------------ Current asXML() behavior of the SimpleXMLElement object is not really neat: this method may accept "filename" as a first argument for data storing on a HDD. However, if a "filename" is empty (let's say "null" or empty string), this method will throw a warning about it. This logic asks from the programmer create very strange structures to avoid such warning messages: "if ($filename) { return $xml->asXML($filename); } else { return $xml->asXML(); }" Test script: --------------- <?php function example($file_path = null) { $xml = new \SimpleXMLElement('<data></data>'); return $xml->asXML($file_path); } example(); # will throw "PHP Warning: SimpleXMLElement::asXML(): Filename cannot be empty in ..." Expected result: ---------------- I suggest to make a "filename" as an optional argument for this method. Actual result: -------------- PHP Warning: SimpleXMLElement::asXML(): Filename cannot be empty in ...