3v4l.org

run code in 300+ PHP versions simultaneously
<?php class testParser { /** @var resource */ private $parser; /** * @param string $encoding */ public function __construct($encoding = 'UTF-8') { echo __CLASS__ . ' ' . __METHOD__ . ' ' . __LINE__ . "<br>"; $parser = new ParserObject($encoding); $this->parser = $parser->getParser(); xml_set_character_data_handler($this->parser, [$this, 'data']); echo __CLASS__ . ' ' . __METHOD__ . ' ' . __LINE__ . "<br>"; } public function parseAction($data) { echo __CLASS__ . ' ' . __METHOD__ . ' ' . __LINE__ . "<br>"; return xml_parse($this->parser, $data); } public function data($parser, $cdata) { echo __CLASS__ . ' ' . __METHOD__ . ' ' . __LINE__ . "<br>"; } } class ParserObject { /** @var resource */ private $xml_parser_resource; public function __construct($encoding) { echo __CLASS__ . ' ' . __METHOD__ . ' ' . __LINE__ . "<br>"; $this->xml_parser_resource = xml_parser_create($encoding); } public function getParser() { echo __CLASS__ . ' ' . __METHOD__ . ' ' . __LINE__ . "<br>"; return $this->xml_parser_resource; } public function __destruct() { echo __CLASS__ . ' ' . __METHOD__ . ' ' . __LINE__ . "<br>"; xml_parser_free($this->xml_parser_resource); } } $content = '<?xml version="1.0" ?><note><body>Do</body></note>'; echo __LINE__ . "<br>"; $parser = new testParser(); echo __LINE__ . "<br>"; $parser->parseAction($content); echo __LINE__ . "<br>";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jCBM4
function name:  (null)
number of ops:  11
compiled vars:  !0 = $content, !1 = $parser
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22+%3F%3E%3Cnote%3E%3Cbody%3EDo%3C%2Fbody%3E%3C%2Fnote%3E'
   58     1        ECHO                                                     '58%3Cbr%3E'
   59     2        NEW                                              $3      'testParser'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $3
   60     5        ECHO                                                     '60%3Cbr%3E'
   61     6        INIT_METHOD_CALL                                         !1, 'parseAction'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
   62     9        ECHO                                                     '62%3Cbr%3E'
         10      > RETURN                                                   1

Class testParser:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jCBM4
function name:  __construct
number of ops:  20
compiled vars:  !0 = $encoding, !1 = $parser
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV_INIT                                        !0      'UTF-8'
   13     1        ECHO                                                     'testParser+testParser%3A%3A__construct+13%3Cbr%3E'
   14     2        NEW                                              $2      'ParserObject'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $2
   15     6        INIT_METHOD_CALL                                         !1, 'getParser'
          7        DO_FCALL                                      0  $6      
          8        ASSIGN_OBJ                                               'parser'
          9        OP_DATA                                                  $6
   16    10        INIT_FCALL                                               'xml_set_character_data_handler'
         11        FETCH_OBJ_R                                      ~7      'parser'
         12        SEND_VAL                                                 ~7
         13        FETCH_THIS                                       ~8      
         14        INIT_ARRAY                                       ~9      ~8
         15        ADD_ARRAY_ELEMENT                                ~9      'data'
         16        SEND_VAL                                                 ~9
         17        DO_ICALL                                                 
   17    18        ECHO                                                     'testParser+testParser%3A%3A__construct+17%3Cbr%3E'
   18    19      > RETURN                                                   null

End of function __construct

Function parseaction:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jCBM4
function name:  parseAction
number of ops:  9
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        ECHO                                                     'testParser+testParser%3A%3AparseAction+22%3Cbr%3E'
   23     2        INIT_FCALL                                               'xml_parse'
          3        FETCH_OBJ_R                                      ~1      'parser'
          4        SEND_VAL                                                 ~1
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
   24     8*     > RETURN                                                   null

End of function parseaction

Function data:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jCBM4
function name:  data
number of ops:  4
compiled vars:  !0 = $parser, !1 = $cdata
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   28     2        ECHO                                                     'testParser+testParser%3A%3Adata+28%3Cbr%3E'
   29     3      > RETURN                                                   null

End of function data

End of class testParser.

Class ParserObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jCBM4
function name:  __construct
number of ops:  8
compiled vars:  !0 = $encoding
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   39     1        ECHO                                                     'ParserObject+ParserObject%3A%3A__construct+39%3Cbr%3E'
   40     2        INIT_FCALL                                               'xml_parser_create'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        ASSIGN_OBJ                                               'xml_parser_resource'
          6        OP_DATA                                                  $2
   41     7      > RETURN                                                   null

End of function __construct

Function getparser:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jCBM4
function name:  getParser
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   ECHO                                                     'ParserObject+ParserObject%3A%3AgetParser+45%3Cbr%3E'
   46     1        FETCH_OBJ_R                                      ~0      'xml_parser_resource'
          2      > RETURN                                                   ~0
   47     3*     > RETURN                                                   null

End of function getparser

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jCBM4
function name:  __destruct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   ECHO                                                     'ParserObject+ParserObject%3A%3A__destruct+51%3Cbr%3E'
   52     1        INIT_FCALL                                               'xml_parser_free'
          2        FETCH_OBJ_R                                      ~0      'xml_parser_resource'
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                                 
   53     5      > RETURN                                                   null

End of function __destruct

End of class ParserObject.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.9 ms | 1404 KiB | 21 Q