3v4l.org

run code in 200+ php & hhvm versions
<?php function handleCharacterData($parser, $data) { echo __FUNCTION__ . " - " . $data . "\n"; } function handleElementStart($parser, $name, $attributes) { echo __FUNCTION__ . " - " . $name . "\n"; } function handleElementEnd($parser, $name) { echo __FUNCTION__ . " - " . $name . "\n"; } function parseAndOutput($s) { $p = xml_parser_create(); xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1); xml_set_character_data_handler($p, 'handleCharacterData'); xml_set_element_handler($p, 'handleElementStart', 'handleElementEnd'); xml_parse_into_struct($p, $s, $values); echo $values[0]['value'] . "\n\n"; } $s = "<a>b\nc</a>"; parseAndOutput($s); $s = "<a>&lt;b&gt;\n&lt;c&gt;</a>"; parseAndOutput($s);
based on JC8HR
Output for 5.3.20 - 7.3.1
handleElementStart - A handleCharacterData - b c handleElementEnd - A b c handleElementStart - A handleCharacterData - < handleCharacterData - b handleCharacterData - > handleCharacterData - handleCharacterData - < handleCharacterData - c handleCharacterData - > handleElementEnd - A <b><c>