3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Adds a CDATA property to an XML document. * * @param string $name * Name of property that should contain CDATA. * @param string $value * Value that should be inserted into a CDATA child. * @param object $parent * Element that the CDATA child should be attached too. */ $add_cdata = function($name, $value, &$parent) { $child = $parent->addChild($name); if ($child !== NULL) { $child_node = dom_import_simplexml($child); $child_owner = $child_node->ownerDocument; $child_node->appendChild($child_owner->createCDATASection($value)); } return $child; }; $parent = new SimpleXMLElement('<?xml version="1.0"?><ITEM />'); $child = $add_cdata('name', 'DELL S2721DGFA 68,5cm (27") WQHD IPS', $parent); echo $parent->asXML(), "\n"; echo $child->asXML(), "\n";
Output for git.master, git.master_jit, rfc.property-hooks
<?xml version="1.0"?> <ITEM><name><![CDATA[DELL S2721DGFA 68,5cm (27") WQHD IPS]]></name></ITEM> <name><![CDATA[DELL S2721DGFA 68,5cm (27") WQHD IPS]]></name>

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:
91.44 ms | 405 KiB | 5 Q