3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <div> <p>Paragraph one is okay </p> <h2>This will work without problem</h2> <p>Paragraph two is okay </p> <h2>This heading too</h2> <p>Paragraph one is okay </p> <h2>This item list will work too</h2> <p>Paragraph two is okay </p> <h3>1. <a href="https://www.example1.com/">This wont work</a></h3> <p>Paragraph one is okay </p> <h3>2. <a href="https://www.example2.com/">Not working</a></h3> <p>Paragraph two is okay </p> <h3>3. Neither this one</h3> <h3>But this works again</h3> </div> HTML; $dom = new DOMDocument; $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); foreach ($xpath->query("//h2 | //h3") as $node) { echo var_export($node->nodeValue, true) . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 25
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 25
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/LGJK9
function name:  (null)
number of ops:  27
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cdiv%3E%0A%3Cp%3EParagraph+one+is+okay+%3C%2Fp%3E%0A%3Ch2%3EThis+will+work+without+problem%3C%2Fh2%3E%0A%3Cp%3EParagraph+two+is+okay+%3C%2Fp%3E%0A%3Ch2%3EThis+heading+too%3C%2Fh2%3E%0A%3Cp%3EParagraph+one+is+okay+%3C%2Fp%3E%0A%3Ch2%3EThis+item+list+will+work+too%3C%2Fh2%3E%0A%3Cp%3EParagraph+two+is+okay+%3C%2Fp%3E%0A%3Ch3%3E1.+%3Ca+href%3D%22https%3A%2F%2Fwww.example1.com%2F%22%3EThis+wont+work%3C%2Fa%3E%3C%2Fh3%3E%0A%3Cp%3EParagraph+one+is+okay+%3C%2Fp%3E%0A%3Ch3%3E2.+%3Ca+href%3D%22https%3A%2F%2Fwww.example2.com%2F%22%3ENot+working%3C%2Fa%3E%3C%2Fh3%3E%0A%3Cp%3EParagraph+two+is+okay+%3C%2Fp%3E%0A%3Ch3%3E3.+Neither+this+one%3C%2Fh3%3E%0A%3Ch3%3EBut+this+works+again%3C%2Fh3%3E%0A%3C%2Fdiv%3E'
   20     1        NEW                                              $5      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
   21     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              8196
          7        DO_FCALL                                      0          
   22     8        NEW                                              $9      'DOMXPath'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $9
   23    12        INIT_METHOD_CALL                                         !2, 'query'
         13        SEND_VAL_EX                                              '%2F%2Fh2+%7C+%2F%2Fh3'
         14        DO_FCALL                                      0  $12     
         15      > FE_RESET_R                                       $13     $12, ->25
         16    > > FE_FETCH_R                                               $13, !3, ->25
   24    17    >   INIT_FCALL                                               'var_export'
         18        FETCH_OBJ_R                                      ~14     !3, 'nodeValue'
         19        SEND_VAL                                                 ~14
         20        SEND_VAL                                                 <true>
         21        DO_ICALL                                         $15     
         22        CONCAT                                           ~16     $15, '%0A'
         23        ECHO                                                     ~16
   23    24      > JMP                                                      ->16
         25    >   FE_FREE                                                  $13
   25    26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.68 ms | 1396 KiB | 15 Q