3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <body> <a href="page4.php">Page 4</a> <a href="page3.php">Page 3</a> <div class="red">stuff</div> <div class="blue">stuff</div> </body> HTML; $dom = new DOMDocument; $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $counter = 0; foreach ($dom->getElementsByTagName("a") as $a) { ++$counter; $comment = new DOMComment(" UNIT $counter "); $a->parentNode->insertBefore($comment, $a); $a->setAttribute('id', "a_$counter"); } $counter = 0; foreach ($dom->getElementsByTagName("div") as $b) { ++$counter; $b->setAttribute('id', "b_$counter"); } echo substr($dom->saveHTML(), 7, -9);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 34
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 34
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 34
2 jumps found. (Code = 77) Position 1 = 40, Position 2 = 49
Branch analysis from position: 40
2 jumps found. (Code = 78) Position 1 = 41, Position 2 = 49
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
Branch analysis from position: 34
filename:       /in/ALmsS
function name:  (null)
number of ops:  59
compiled vars:  !0 = $html, !1 = $dom, !2 = $counter, !3 = $a, !4 = $comment, !5 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cbody%3E%0A%3Ca+href%3D%22page4.php%22%3EPage+4%3C%2Fa%3E%0A%3Ca+href%3D%22page3.php%22%3EPage+3%3C%2Fa%3E%0A%3Cdiv+class%3D%22red%22%3Estuff%3C%2Fdiv%3E%0A%3Cdiv+class%3D%22blue%22%3Estuff%3C%2Fdiv%3E%0A%3C%2Fbody%3E'
   12     1        NEW                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
   13     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              8196
          7        DO_FCALL                                      0          
   14     8        ASSIGN                                                   !2, 0
   15     9        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         10        SEND_VAL_EX                                              'a'
         11        DO_FCALL                                      0  $12     
         12      > FE_RESET_R                                       $13     $12, ->34
         13    > > FE_FETCH_R                                               $13, !3, ->34
   16    14    >   PRE_INC                                                  !2
   17    15        NEW                                              $15     'DOMComment'
         16        ROPE_INIT                                     3  ~17     '+UNIT+'
         17        ROPE_ADD                                      1  ~17     ~17, !2
         18        ROPE_END                                      2  ~16     ~17, '+'
         19        SEND_VAL_EX                                              ~16
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !4, $15
   18    22        FETCH_OBJ_R                                      ~21     !3, 'parentNode'
         23        INIT_METHOD_CALL                                         ~21, 'insertBefore'
         24        SEND_VAR_EX                                              !4
         25        SEND_VAR_EX                                              !3
         26        DO_FCALL                                      0          
   19    27        INIT_METHOD_CALL                                         !3, 'setAttribute'
         28        SEND_VAL_EX                                              'id'
         29        NOP                                                      
         30        FAST_CONCAT                                      ~23     'a_', !2
         31        SEND_VAL_EX                                              ~23
         32        DO_FCALL                                      0          
   15    33      > JMP                                                      ->13
         34    >   FE_FREE                                                  $13
   21    35        ASSIGN                                                   !2, 0
   22    36        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         37        SEND_VAL_EX                                              'div'
         38        DO_FCALL                                      0  $26     
         39      > FE_RESET_R                                       $27     $26, ->49
         40    > > FE_FETCH_R                                               $27, !5, ->49
   23    41    >   PRE_INC                                                  !2
   24    42        INIT_METHOD_CALL                                         !5, 'setAttribute'
         43        SEND_VAL_EX                                              'id'
         44        NOP                                                      
         45        FAST_CONCAT                                      ~29     'b_', !2
         46        SEND_VAL_EX                                              ~29
         47        DO_FCALL                                      0          
   22    48      > JMP                                                      ->40
         49    >   FE_FREE                                                  $27
   26    50        INIT_FCALL                                               'substr'
         51        INIT_METHOD_CALL                                         !1, 'saveHTML'
         52        DO_FCALL                                      0  $31     
         53        SEND_VAR                                                 $31
         54        SEND_VAL                                                 7
         55        SEND_VAL                                                 -9
         56        DO_ICALL                                         $32     
         57        ECHO                                                     $32
         58      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.81 ms | 1002 KiB | 14 Q