note 126356 added to simplexmlelement.construct

From: Date: Fri, 20 Aug 2021 16:22:19 +0000
Subject: note 126356 added to simplexmlelement.construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-216815@lists.php.net to get a copy of this message
Extended SimpleXMLElement: <?php class XmlElement extends \SimpleXMLElement { public static function factory(string $root): self { return new static('<?xml version="1.0" encoding="UTF-8"?><'.$root.'/>', LIBXML_BIGLINES | LIBXML_COMPACT); } /** * @param iterable $attributes An array of element attributes as name/value pairs * @return $this */ public function addAttributes(iterable $attributes) { foreach ($attributes as $name => $value) { $this->addAttribute($name, $value); } return $this; } /** * @param string $name The sub-element name * @param string|array|null $valueOrAttributes The sub-element value or an array of attributes * @param string|null $namespace The sub-element namespace * @return static|null */ public function addChild($name, $valueOrAttributes = null, $namespace = null) { if (is_array($valueOrAttributes)) { $child = parent::addChild($name, null, $namespace); foreach ($valueOrAttributes as $name => $value) { $child->addAttribute($name, $value); } } else { $child = parent::addChild($name, $valueOrAttributes, $namespace); } return $child; } /** * @param iterable $childs An array of sub-elements as name/value(or attributes) pairs * @return $this */ public function addChilds(iterable $childs) { foreach ($childs as $name => $value) { $this->addChild($name, $value); } return $this; } } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 31.129.215.166) ---- Manual Page -- https://php.net/manual/en/simplexmlelement.construct.php Edit -- https://main.php.net/note/edit/126356 Del: integrated -- https://main.php.net/note/delete/126356/integrated Del: useless -- https://main.php.net/note/delete/126356/useless Del: bad code -- https://main.php.net/note/delete/126356/bad+code Del: spam -- https://main.php.net/note/delete/126356/spam Del: non-english -- https://main.php.net/note/delete/126356/non-english Del: in docs -- https://main.php.net/note/delete/126356/in+docs Del: other reasons-- https://main.php.net/note/delete/126356 Reject -- https://main.php.net/note/reject/126356 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#216815) next »