3v4l.org

run code in 500+ PHP versions simultaneously
<?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);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TD9v
function name:  (null)
number of ops:  9
compiled vars:  !0 = $s
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                       !0, '%3Ca%3Eb%0Ac%3C%2Fa%3E'
   30     1        INIT_FCALL                                                   'parseandoutput'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0          
   32     4        ASSIGN                                                       !0, '%3Ca%3E%26lt%3Bb%26gt%3B%0A%26lt%3Bc%26gt%3B%3C%2Fa%3E'
   33     5        INIT_FCALL                                                   'parseandoutput'
          6        SEND_VAR                                                     !0
          7        DO_FCALL                                          0          
          8      > RETURN                                                       1

Function handlecharacterdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TD9v
function name:  handleCharacterData
number of ops:  6
compiled vars:  !0 = $parser, !1 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    5     2        CONCAT                                               ~2      'handleCharacterData+-+', !1
          3        CONCAT                                               ~3      ~2, '%0A'
          4        ECHO                                                         ~3
    6     5      > RETURN                                                       null

End of function handlecharacterdata

Function handleelementstart:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TD9v
function name:  handleElementStart
number of ops:  7
compiled vars:  !0 = $parser, !1 = $name, !2 = $attributes
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   10     3        CONCAT                                               ~3      'handleElementStart+-+', !1
          4        CONCAT                                               ~4      ~3, '%0A'
          5        ECHO                                                         ~4
   11     6      > RETURN                                                       null

End of function handleelementstart

Function handleelementend:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TD9v
function name:  handleElementEnd
number of ops:  6
compiled vars:  !0 = $parser, !1 = $name
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   15     2        CONCAT                                               ~2      'handleElementEnd+-+', !1
          3        CONCAT                                               ~3      ~2, '%0A'
          4        ECHO                                                         ~3
   16     5      > RETURN                                                       null

End of function handleelementend

Function parseandoutput:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4TD9v
function name:  parseAndOutput
number of ops:  28
compiled vars:  !0 = $s, !1 = $p, !2 = $values
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
   20     1        INIT_FCALL                                                   'xml_parser_create'
          2        DO_ICALL                                             $3      
          3        ASSIGN                                                       !1, $3
   21     4        INIT_FCALL                                                   'xml_parser_set_option'
          5        SEND_VAR                                                     !1
          6        SEND_VAL                                                     4
          7        SEND_VAL                                                     1
          8        DO_ICALL                                                     
   22     9        INIT_FCALL                                                   'xml_set_character_data_handler'
         10        SEND_VAR                                                     !1
         11        SEND_VAL                                                     'handleCharacterData'
         12        DO_ICALL                                                     
   23    13        INIT_FCALL                                                   'xml_set_element_handler'
         14        SEND_VAR                                                     !1
         15        SEND_VAL                                                     'handleElementStart'
         16        SEND_VAL                                                     'handleElementEnd'
         17        DO_ICALL                                                     
   25    18        INIT_FCALL                                                   'xml_parse_into_struct'
         19        SEND_VAR                                                     !1
         20        SEND_VAR                                                     !0
         21        SEND_REF                                                     !2
         22        DO_ICALL                                                     
   26    23        FETCH_DIM_R                                          ~9      !2, 0
         24        FETCH_DIM_R                                          ~10     ~9, 'value'
         25        CONCAT                                               ~11     ~10, '%0A%0A'
         26        ECHO                                                         ~11
   27    27      > RETURN                                                       null

End of function parseandoutput

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.4 ms | 2857 KiB | 20 Q