3v4l.org

run code in 300+ PHP versions simultaneously
<?php libxml_use_internal_errors(true); $dom = new DOMDocument; $dom->loadHTML('<h1>junk</h1><div>wth?</div>ANYTHING HERE<div class="col"></div>'); $xpath = new DOMXPath($dom); $found = $xpath->query('//div[@class="col"]/preceding-sibling::text()'); if ($found instanceOf DOMNodeList && $found->length > 0) { $text = $found->item(0); $comment = $dom->createComment(''); $text->parentNode->replaceChild($comment, $text); } echo $dom->saveXML($dom->getElementsByTagname('body')->item(0));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 36
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 22
filename:       /in/uWSP7
function name:  (null)
number of ops:  47
compiled vars:  !0 = $dom, !1 = $xpath, !2 = $found, !3 = $text, !4 = $comment
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'libxml_use_internal_errors'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                                 
    3     3        NEW                                              $6      'DOMDocument'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $6
    4     6        INIT_METHOD_CALL                                         !0, 'loadHTML'
          7        SEND_VAL_EX                                              '%3Ch1%3Ejunk%3C%2Fh1%3E%3Cdiv%3Ewth%3F%3C%2Fdiv%3EANYTHING+HERE%3Cdiv+class%3D%22col%22%3E%3C%2Fdiv%3E'
          8        DO_FCALL                                      0          
    5     9        NEW                                              $10     'DOMXPath'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $10
    7    13        INIT_METHOD_CALL                                         !1, 'query'
         14        SEND_VAL_EX                                              '%2F%2Fdiv%5B%40class%3D%22col%22%5D%2Fpreceding-sibling%3A%3Atext%28%29'
         15        DO_FCALL                                      0  $13     
         16        ASSIGN                                                   !2, $13
    8    17        INSTANCEOF                                       ~15     !2, 'DOMNodeList'
         18      > JMPZ_EX                                          ~15     ~15, ->22
         19    >   FETCH_OBJ_R                                      ~16     !2, 'length'
         20        IS_SMALLER                                       ~17     0, ~16
         21        BOOL                                             ~15     ~17
         22    > > JMPZ                                                     ~15, ->36
   10    23    >   INIT_METHOD_CALL                                         !2, 'item'
         24        SEND_VAL_EX                                              0
         25        DO_FCALL                                      0  $18     
         26        ASSIGN                                                   !3, $18
   11    27        INIT_METHOD_CALL                                         !0, 'createComment'
         28        SEND_VAL_EX                                              ''
         29        DO_FCALL                                      0  $20     
         30        ASSIGN                                                   !4, $20
   12    31        FETCH_OBJ_R                                      ~22     !3, 'parentNode'
         32        INIT_METHOD_CALL                                         ~22, 'replaceChild'
         33        SEND_VAR_EX                                              !4
         34        SEND_VAR_EX                                              !3
         35        DO_FCALL                                      0          
   15    36    >   INIT_METHOD_CALL                                         !0, 'saveXML'
         37        INIT_METHOD_CALL                                         !0, 'getElementsByTagname'
         38        SEND_VAL_EX                                              'body'
         39        DO_FCALL                                      0  $24     
         40        INIT_METHOD_CALL                                         $24, 'item'
         41        SEND_VAL_EX                                              0
         42        DO_FCALL                                      0  $25     
         43        SEND_VAR_NO_REF_EX                                       $25
         44        DO_FCALL                                      0  $26     
         45        ECHO                                                     $26
         46      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.22 ms | 1400 KiB | 15 Q