3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html=<<<doc <html> <head> <title>My page</title> <script> //<![CDATA[ $(function(){ $('.ajax').trigger('change'); }) //]]></script> <style>ul li ol li{color;red;}</style> </head> <body> <div> <ul> <li>Languages <ol> <li>PHP</li> <li class='noparse'>C++</li> </ol> </li> </ul> <span>inline text</span> <p class="generic">some long text data</p> <a href="https://stackoverflow.com" title="resource hub">Stack Overflow</a> <a href="https://google.nl" title="Google" class="inline-a noparse otherclass">Google</a> <img class="img-responsive parse round red" src="" alt="round image" /> <img class="img-responsive noparse round red" src="" alt="square image" /> </div> </body> </html> doc; libxml_use_internal_errors(true); $dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->loadHTML($html, LIBXML_SCHEMA_CREATE); $xpath = new DOMXPath($dom); $exclude='.generic,.noparse'; foreach ($xpath->query("//*/text()[not(@class='$exclude')]|//a/@title[not(@class='$exclude')]|//img/@alt[not(@class='$exclude')]") as $node) { $node->textContent=$node->textContent.' powered by sometext'; } echo $dom->saveHTML(); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 35
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/urIBl
function name:  (null)
number of ops:  40
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $exclude, !4 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Chtml%3E%0A%3Chead%3E%0A%3Ctitle%3EMy+page%3C%2Ftitle%3E%0A%3Cscript%3E%0A%2F%2F%3C%21%5BCDATA%5B%0A%0A%24%28function%28%29%7B%0A+++%24%28%27.ajax%27%29.trigger%28%27change%27%29%3B%0A%7D%29%0A%2F%2F%5D%5D%3E%3C%2Fscript%3E%0A%3Cstyle%3Eul+li+ol+li%7Bcolor%3Bred%3B%7D%3C%2Fstyle%3E%0A%3C%2Fhead%3E%0A%3Cbody%3E%0A%3Cdiv%3E%0A%3Cul%3E%0A++++%3Cli%3ELanguages%0A++++++++%3Col%3E%0A++++++++%3Cli%3EPHP%3C%2Fli%3E%0A++++++++%3Cli+class%3D%27noparse%27%3EC%2B%2B%3C%2Fli%3E%0A++++++++%3C%2Fol%3E%0A++++%3C%2Fli%3E%0A%3C%2Ful%3E%0A%3Cspan%3Einline+text%3C%2Fspan%3E%0A%3Cp+class%3D%22generic%22%3Esome+long+text+data%3C%2Fp%3E%0A%3Ca+href%3D%22https%3A%2F%2Fstackoverflow.com%22+title%3D%22resource+hub%22%3EStack+Overflow%3C%2Fa%3E%0A%3Ca+href%3D%22https%3A%2F%2Fgoogle.nl%22+title%3D%22Google%22+class%3D%22inline-a+noparse+otherclass%22%3EGoogle%3C%2Fa%3E%0A%3Cimg+class%3D%22img-responsive+parse+round+red%22+src%3D%22%22+alt%3D%22round+image%22+%2F%3E%0A%3Cimg+class%3D%22img-responsive+noparse+round+red%22+src%3D%22%22+alt%3D%22square+image%22+%2F%3E%0A%3C%2Fdiv%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   39     1        INIT_FCALL                                               'libxml_use_internal_errors'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                                 
   40     4        NEW                                              $7      'DOMDocument'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $7
   41     7        ASSIGN_OBJ                                               !1, 'preserveWhiteSpace'
          8        OP_DATA                                                  <false>
   42     9        INIT_METHOD_CALL                                         !1, 'loadHTML'
         10        SEND_VAR_EX                                              !0
         11        SEND_VAL_EX                                              1
         12        DO_FCALL                                      0          
   43    13        NEW                                              $12     'DOMXPath'
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !2, $12
   46    17        ASSIGN                                                   !3, '.generic%2C.noparse'
   48    18        INIT_METHOD_CALL                                         !2, 'query'
         19        ROPE_INIT                                     7  ~17     '%2F%2F%2A%2Ftext%28%29%5Bnot%28%40class%3D%27'
         20        ROPE_ADD                                      1  ~17     ~17, !3
         21        ROPE_ADD                                      2  ~17     ~17, '%27%29%5D%7C%2F%2Fa%2F%40title%5Bnot%28%40class%3D%27'
         22        ROPE_ADD                                      3  ~17     ~17, !3
         23        ROPE_ADD                                      4  ~17     ~17, '%27%29%5D%7C%2F%2Fimg%2F%40alt%5Bnot%28%40class%3D%27'
         24        ROPE_ADD                                      5  ~17     ~17, !3
         25        ROPE_END                                      6  ~16     ~17, '%27%29%5D'
         26        SEND_VAL_EX                                              ~16
         27        DO_FCALL                                      0  $21     
         28      > FE_RESET_R                                       $22     $21, ->35
         29    > > FE_FETCH_R                                               $22, !4, ->35
   50    30    >   FETCH_OBJ_R                                      ~24     !4, 'textContent'
         31        CONCAT                                           ~25     ~24, '+powered+by+sometext'
         32        ASSIGN_OBJ                                               !4, 'textContent'
         33        OP_DATA                                                  ~25
   48    34      > JMP                                                      ->29
         35    >   FE_FREE                                                  $22
   53    36        INIT_METHOD_CALL                                         !1, 'saveHTML'
         37        DO_FCALL                                      0  $26     
         38        ECHO                                                     $26
   55    39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.67 ms | 1005 KiB | 14 Q