3v4l.org

run code in 300+ PHP versions simultaneously
<?php function countDOMNodesRecursiveInclusive(DOMNode $node){ $ret = 1; var_dump($node->nodeName,$node->nodeValue); if($node->hasChildNodes()){ foreach($node->childNodes as $child){ $ret+=countDOMNodesRecursiveInclusive($child); } } return $ret; } $xml=<<<'XML' <doc><elem> </elem></doc> XML; ($dom=new DOMDocument())->loadXML($xml,LIBXML_NOBLANKS); echo countDOMNodesRecursiveInclusive($dom);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gXHvV
function name:  (null)
number of ops:  13
compiled vars:  !0 = $xml, !1 = $dom
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, '%3Cdoc%3E%3Celem%3E+%3C%2Felem%3E%3C%2Fdoc%3E'
   16     1        NEW                                              $3      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                           ~5      !1, $3
          4        INIT_METHOD_CALL                                         ~5, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              256
          7        DO_FCALL                                      0          
   17     8        INIT_FCALL                                               'countdomnodesrecursiveinclusive'
          9        SEND_VAR                                                 !1
         10        DO_FCALL                                      0  $7      
         11        ECHO                                                     $7
         12      > RETURN                                                   1

Function countdomnodesrecursiveinclusive:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 19
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
Branch analysis from position: 20
filename:       /in/gXHvV
function name:  countDOMNodesRecursiveInclusive
number of ops:  22
compiled vars:  !0 = $node, !1 = $ret, !2 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, 1
    5     2        INIT_FCALL                                               'var_dump'
          3        FETCH_OBJ_R                                      ~4      !0, 'nodeName'
          4        SEND_VAL                                                 ~4
          5        FETCH_OBJ_R                                      ~5      !0, 'nodeValue'
          6        SEND_VAL                                                 ~5
          7        DO_ICALL                                                 
    6     8        INIT_METHOD_CALL                                         !0, 'hasChildNodes'
          9        DO_FCALL                                      0  $7      
         10      > JMPZ                                                     $7, ->20
    7    11    >   FETCH_OBJ_R                                      ~8      !0, 'childNodes'
         12      > FE_RESET_R                                       $9      ~8, ->19
         13    > > FE_FETCH_R                                               $9, !2, ->19
    8    14    >   INIT_FCALL_BY_NAME                                       'countDOMNodesRecursiveInclusive'
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0  $10     
         17        ASSIGN_OP                                     1          !1, $10
    7    18      > JMP                                                      ->13
         19    >   FE_FREE                                                  $9
   11    20    > > RETURN                                                   !1
   12    21*     > RETURN                                                   null

End of function countdomnodesrecursiveinclusive

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.64 ms | 1017 KiB | 15 Q