3v4l.org

run code in 300+ PHP versions simultaneously
<?php function printList(\DOMNodeList $list) { foreach ($list as $outer) { /* @var $outer \DOMNode */ echo 'outer: ' . $outer->nodeValue . PHP_EOL; foreach ($list as $inner) { /* @var $inner \DOMNode */ echo ' inner: ' . $inner->nodeValue . PHP_EOL; } } } /** * @return DOMNodeList */ function getByXpath(\DOMDocument $dom) { return (new \DOMXPath($dom))->evaluate('item'); } /** * @return DOMNodeList */ function getByTagName(\DOMDocument $dom) { return $dom->getElementsByTagName('item'); } $xml = <<< XML <root> <item>1</item> <item>2</item> <item>3</item> </root> XML; $dom = new \DOMDocument; $dom->loadXml($xml); printList(getByTagName($dom)); echo '-------------' . PHP_EOL; printList(getByXpath($dom));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FXAuR
function name:  (null)
number of ops:  21
compiled vars:  !0 = $xml, !1 = $dom
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   ASSIGN                                                   !0, '%3Croot%3E%0A++%3Citem%3E1%3C%2Fitem%3E%0A++%3Citem%3E2%3C%2Fitem%3E%0A++%3Citem%3E3%3C%2Fitem%3E%0A%3C%2Froot%3E'
   38     1        NEW                                              $3      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $3
   39     4        INIT_METHOD_CALL                                         !1, 'loadXml'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   41     7        INIT_FCALL                                               'printlist'
          8        INIT_FCALL                                               'getbytagname'
          9        SEND_VAR                                                 !1
         10        DO_FCALL                                      0  $7      
         11        SEND_VAR                                                 $7
         12        DO_FCALL                                      0          
   42    13        ECHO                                                     '-------------%0A'
   43    14        INIT_FCALL                                               'printlist'
         15        INIT_FCALL                                               'getbyxpath'
         16        SEND_VAR                                                 !1
         17        DO_FCALL                                      0  $9      
         18        SEND_VAR                                                 $9
         19        DO_FCALL                                      0          
         20      > RETURN                                                   1

Function printlist:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 16
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 14
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/FXAuR
function name:  printList
number of ops:  18
compiled vars:  !0 = $list, !1 = $outer, !2 = $inner
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1      > FE_RESET_R                                       $3      !0, ->16
          2    > > FE_FETCH_R                                               $3, !1, ->16
    7     3    >   FETCH_OBJ_R                                      ~4      !1, 'nodeValue'
          4        CONCAT                                           ~5      'outer%3A+', ~4
          5        CONCAT                                           ~6      ~5, '%0A'
          6        ECHO                                                     ~6
    8     7      > FE_RESET_R                                       $7      !0, ->14
          8    > > FE_FETCH_R                                               $7, !2, ->14
   10     9    >   FETCH_OBJ_R                                      ~8      !2, 'nodeValue'
         10        CONCAT                                           ~9      '+inner%3A+', ~8
         11        CONCAT                                           ~10     ~9, '%0A'
         12        ECHO                                                     ~10
    8    13      > JMP                                                      ->8
         14    >   FE_FREE                                                  $7
    5    15      > JMP                                                      ->2
         16    >   FE_FREE                                                  $3
   13    17      > RETURN                                                   null

End of function printlist

Function getbyxpath:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FXAuR
function name:  getByXpath
number of ops:  9
compiled vars:  !0 = $dom
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        NEW                                              $1      'DOMXPath'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        INIT_METHOD_CALL                                         $1, 'evaluate'
          5        SEND_VAL_EX                                              'item'
          6        DO_FCALL                                      0  $3      
          7      > RETURN                                                   $3
   21     8*     > RETURN                                                   null

End of function getbyxpath

Function getbytagname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FXAuR
function name:  getByTagName
number of ops:  6
compiled vars:  !0 = $dom
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   27     1        INIT_METHOD_CALL                                         !0, 'getElementsByTagName'
          2        SEND_VAL_EX                                              'item'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   28     5*     > RETURN                                                   null

End of function getbytagname

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.24 ms | 1407 KiB | 17 Q