3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MySimpleXMLElement extends SimpleXMLElement{ public function appendXML($append) { if ($append) { if (strlen(trim((string)$append)) == 0) { $xml = $this->addChild($append->getName()); } else { $xml = $this->addChild($append->getName(), (string)$append); }  foreach ($append->children() as $child) { $xml->appendXML($child); }  foreach ($append->attributes() as $n => $v) { $xml->addAttribute($n, $v); } } }} $currentPayment = new SimpleXMLElement('<payment></payment>');$currentPayment->addChild('creditCard');$currentPayment->creditCard->addChild('cardNumber', 'XXXX0027');$currentPayment->creditCard->addChild('expirationDate', 'XXXX'); $paymentProfile = new MySimpleXMLElement('<paymentProfile></paymentProfile>'); $paymentProfile->appendXML($currentPayment); echo $paymentProfile->asXML();
Output for git.master, git.master_jit, rfc.property-hooks
<?php class MySimpleXMLElement extends SimpleXMLElement{ public function appendXML($append) { if ($append) { if (strlen(trim((string)$append)) == 0) { $xml = $this->addChild($append->getName()); } else { $xml = $this->addChild($append->getName(), (string)$append); }  foreach ($append->children() as $child) { $xml->appendXML($child); }  foreach ($append->attributes() as $n => $v) { $xml->addAttribute($n, $v); } } }} $currentPayment = new SimpleXMLElement('<payment></payment>');$currentPayment->addChild('creditCard');$currentPayment->creditCard->addChild('cardNumber', 'XXXX0027');$currentPayment->creditCard->addChild('expirationDate', 'XXXX'); $paymentProfile = new MySimpleXMLElement('<paymentProfile></paymentProfile>'); $paymentProfile->appendXML($currentPayment); echo $paymentProfile->asXML();

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
40.63 ms | 403 KiB | 8 Q