3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<< HTML <html> <head> <title>A Simple HTML Document</title> </head> <body> <p>This is a very simple HTML document</p> <p>It only has two paragraphs</p> </body> </html> HTML; $dom = new DomDocument; $dom->loadHtml($html); listAllNodes($dom->getElementsByTagName('body')[0]); function listAllNodes(DomNode $node) { echo "{$node->nodeName}: {$node->textContent}\n"; foreach ($node->childNodes ?: [] as $node) { listAllNodes($node); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KG8uS
function name:  (null)
number of ops:  17
compiled vars:  !0 = $html, !1 = $dom
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Chtml%3E%0A%3Chead%3E%0A++%3Ctitle%3EA+Simple+HTML+Document%3C%2Ftitle%3E%0A%3C%2Fhead%3E%0A%3Cbody%3E%0A++%3Cp%3EThis+is+a+very+simple+HTML+document%3C%2Fp%3E%0A++%3Cp%3EIt+only+has+two+paragraphs%3C%2Fp%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   15     1        NEW                                              $3      'DomDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $3
   16     4        INIT_METHOD_CALL                                         !1, 'loadHtml'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   18     7        INIT_FCALL_BY_NAME                                       'listAllNodes'
          8        CHECK_FUNC_ARG                                           
          9        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         10        SEND_VAL_EX                                              'body'
         11        DO_FCALL                                      0  $7      
         12        SEPARATE                                         $7      $7
         13        FETCH_DIM_FUNC_ARG                               $8      $7, 0
         14        SEND_FUNC_ARG                                            $8
         15        DO_FCALL                                      0          
   25    16      > RETURN                                                   1

Function listallnodes:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/KG8uS
function name:  listAllNodes
number of ops:  19
compiled vars:  !0 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        FETCH_OBJ_R                                      ~1      !0, 'nodeName'
          2        ROPE_INIT                                     4  ~4      ~1
          3        ROPE_ADD                                      1  ~4      ~4, '%3A+'
          4        FETCH_OBJ_R                                      ~2      !0, 'textContent'
          5        ROPE_ADD                                      2  ~4      ~4, ~2
          6        ROPE_END                                      3  ~3      ~4, '%0A'
          7        ECHO                                                     ~3
   22     8        FETCH_OBJ_R                                      ~6      !0, 'childNodes'
          9        JMP_SET                                          ~7      ~6, ->11
         10        QM_ASSIGN                                        ~7      <array>
         11      > FE_RESET_R                                       $8      ~7, ->17
         12    > > FE_FETCH_R                                               $8, !0, ->17
   23    13    >   INIT_FCALL_BY_NAME                                       'listAllNodes'
         14        SEND_VAR_EX                                              !0
         15        DO_FCALL                                      0          
   22    16      > JMP                                                      ->12
         17    >   FE_FREE                                                  $8
   25    18      > RETURN                                                   null

End of function listallnodes

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.28 ms | 1403 KiB | 13 Q