3v4l.org

run code in 500+ PHP versions simultaneously
<?php $pageHTML = '<html> <head></head> <body> <header> <div> <nav>Menu</nav> <span>Another text</span> </div> </header> <section>Section</section> <footer>Footer</footer> </body> </html>'; $dom = new DOMDocument; libxml_use_internal_errors(true); $dom->loadHTML($pageHTML); libxml_use_internal_errors(false); $xpath = new DOMXpath($dom); foreach($xpath->query('/html/body/header/div/*') as $i) { $i->setAttribute('class','my_class'); } echo $dom->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/047Iq
function name:  (null)
number of ops:  32
compiled vars:  !0 = $pageHTML, !1 = $dom, !2 = $xpath, !3 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%3Chtml%3E%0A%3Chead%3E%3C%2Fhead%3E%0A%3Cbody%3E%0A%0A%3Cheader%3E%0A++%3Cdiv%3E%0A++++%3Cnav%3EMenu%3C%2Fnav%3E%0A++++%3Cspan%3EAnother+text%3C%2Fspan%3E%0A++%3C%2Fdiv%3E%0A%3C%2Fheader%3E%0A%0A%3Csection%3ESection%3C%2Fsection%3E%0A%3Cfooter%3EFooter%3C%2Ffooter%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   19     1        NEW                                                  $5      'DOMDocument'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $5
   20     4        INIT_FCALL                                                   'libxml_use_internal_errors'
          5        SEND_VAL                                                     <true>
          6        DO_ICALL                                                     
   21     7        INIT_METHOD_CALL                                             !1, 'loadHTML'
          8        SEND_VAR_EX                                                  !0
          9        DO_FCALL                                          0          
   22    10        INIT_FCALL                                                   'libxml_use_internal_errors'
         11        SEND_VAL                                                     <false>
         12        DO_ICALL                                                     
   23    13        NEW                                                  $11     'DOMXpath'
         14        SEND_VAR_EX                                                  !1
         15        DO_FCALL                                          0          
         16        ASSIGN                                                       !2, $11
   24    17        INIT_METHOD_CALL                                             !2, 'query'
         18        SEND_VAL_EX                                                  '%2Fhtml%2Fbody%2Fheader%2Fdiv%2F%2A'
         19        DO_FCALL                                          0  $14     
         20      > FE_RESET_R                                           $15     $14, ->27
         21    > > FE_FETCH_R                                                   $15, !3, ->27
   25    22    >   INIT_METHOD_CALL                                             !3, 'setAttribute'
         23        SEND_VAL_EX                                                  'class'
         24        SEND_VAL_EX                                                  'my_class'
         25        DO_FCALL                                          0          
   24    26      > JMP                                                          ->21
         27    >   FE_FREE                                                      $15
   27    28        INIT_METHOD_CALL                                             !1, 'saveHTML'
         29        DO_FCALL                                          0  $17     
         30        ECHO                                                         $17
         31      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.12 ms | 2066 KiB | 14 Q