3v4l.org

run code in 300+ PHP versions simultaneously
<!DOCTYPE html> <html> <head> INSERT VALUES OF THE GIVEN PHRASE IDS :</head> <!-- <head> <link rel="stylesheet" type="text/css" href="style.css" /></head> --> <body> <form name="form" action="edit.php" method="post"> <?php $file = <<<XML <?xml version="1.0"?> <?xml-stylesheet href="catalog.xsl" type="text/xsl"?> <!DOCTYPE catalog SYSTEM "catalog.dtd"> <catalog> <product description="Cardigan Sweater" id="123" value="" product_image="cardigan.jpg"> <catalog_item gender="Men's"> <size description="Medium"> <color_swatch image="red_cardigan.jpg" id="color" value="Red"/> <color_swatch image="burgundy_cardigan.jpg" id="color" value="burgundy"/> </size> <size description="Large"> <color_swatch image="red_cardigan.jpg" id="color" value="Red"/> <color_swatch image="burgundy_cardigan.jpg" id="color" value="burgundy"/> </size> </catalog_item> </product> </catalog> XML; /** * @param SimpleXMLElement $node current node to process * @param int $level Depth in the XML tree * @param string $fieldPrefix */ function makeNodeField(SimpleXMLElement $node, $level, $fieldPrefix = "") { // Indentation with the node level $indent = str_repeat(" ", $level); echo $indent, $node->getName(), PHP_EOL;echo "<br/>"; $fieldName = $fieldPrefix; // If there's an ID on the node, display it and show a text field if (isset($node['id'])) { echo $indent, strval($node['id']), ' '; if (!empty($fieldPrefix)) { $fieldName .= '__'; } $fieldName .= $node->getName() . '__' . strval($node['id']); printf('<input type="text" name="%s" value="%s" /><br/>', $fieldName, strval($node['value']));echo "<br/>"; echo PHP_EOL; } $count = 0; foreach ($node as $childNode) { // put a prefix in the children field name to get a valid field name for POST $childPrefix = $fieldName; if (!empty($fieldPrefix)) { $childPrefix = $fieldName . '__' . $count++; } makeNodeField($childNode, $level + 1, $childPrefix); } } $xml = simplexml_load_string($file); makeNodeField($xml, 0); ?> <input type='submit' name='submit'> </form> </body> </html>
Output for 5.1.3 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
<!DOCTYPE html> <html> <head> INSERT VALUES OF THE GIVEN PHRASE IDS :</head> <!-- <head> <link rel="stylesheet" type="text/css" href="style.css" /></head> --> <body> <form name="form" action="edit.php" method="post"> catalog <br/> product <br/> 123 <input type="text" name="product__123" value="" /><br/><br/> catalog_item <br/> size <br/> color_swatch <br/> color <input type="text" name="product__123__0__0__color_swatch__color" value="Red" /><br/><br/> color_swatch <br/> color <input type="text" name="product__123__0__1__color_swatch__color" value="burgundy" /><br/><br/> size <br/> color_swatch <br/> color <input type="text" name="product__123__1__0__color_swatch__color" value="Red" /><br/><br/> color_swatch <br/> color <input type="text" name="product__123__1__1__color_swatch__color" value="burgundy" /><br/><br/> <input type='submit' name='submit'> </form> </body> </html>
Output for 5.1.2
<!DOCTYPE html> <html> <head> INSERT VALUES OF THE GIVEN PHRASE IDS :</head> <!-- <head> <link rel="stylesheet" type="text/css" href="style.css" /></head> --> <body> <form name="form" action="edit.php" method="post"> Fatal error: Call to undefined method SimpleXMLElement::getName() in /in/TXGBa on line 40
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.1
<!DOCTYPE html> <html> <head> INSERT VALUES OF THE GIVEN PHRASE IDS :</head> <!-- <head> <link rel="stylesheet" type="text/css" href="style.css" /></head> --> <body> <form name="form" action="edit.php" method="post"> Fatal error: Call to undefined method SimpleXMLElement::getName() in /in/TXGBa on line 39
Process exited with code 255.
Output for 4.4.3 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/TXGBa on line 34
Process exited with code 255.
Output for 4.4.2
Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/TXGBa on line 35
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting ')' in /in/TXGBa on line 34
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/TXGBa on line 34
Process exited with code 255.

preferences:
251.09 ms | 401 KiB | 461 Q