3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<img alt="äöü" class="foo" src="bar"><a href="target1">link text 1</a><a class="foo" src="target2">link text 2</a><div class="foo">xxx</div>'; $contentType = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; $doc = new DOMDocument('1.0'); $doc->loadHTML($contentType . $html, LIBXML_NOERROR); $xp = new DOMXPath($doc); foreach ($xp->query('//*[contains(@class, "foo") and (self::a or self::img)]') as $el) { echo $el->ownerDocument->saveHTML($el) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 27
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/SNRue
function name:  (null)
number of ops:  29
compiled vars:  !0 = $html, !1 = $contentType, !2 = $doc, !3 = $xp, !4 = $el
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cimg+alt%3D%22%C3%A4%C3%B6%C3%BC%22+class%3D%22foo%22+src%3D%22bar%22%3E%3Ca+href%3D%22target1%22%3Elink+text+1%3C%2Fa%3E%3Ca+class%3D%22foo%22+src%3D%22target2%22%3Elink+text+2%3C%2Fa%3E%3Cdiv+class%3D%22foo%22%3Exxx%3C%2Fdiv%3E'
    5     1        ASSIGN                                                   !1, '%3Cmeta+http-equiv%3D%22Content-Type%22+content%3D%22text%2Fhtml%3B+charset%3Dutf-8%22%3E'
    6     2        NEW                                              $7      'DOMDocument'
          3        SEND_VAL_EX                                              '1.0'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $7
    7     6        INIT_METHOD_CALL                                         !2, 'loadHTML'
          7        CONCAT                                           ~10     !1, !0
          8        SEND_VAL_EX                                              ~10
          9        SEND_VAL_EX                                              32
         10        DO_FCALL                                      0          
    9    11        NEW                                              $12     'DOMXPath'
         12        SEND_VAR_EX                                              !2
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !3, $12
   10    15        INIT_METHOD_CALL                                         !3, 'query'
         16        SEND_VAL_EX                                              '%2F%2F%2A%5Bcontains%28%40class%2C+%22foo%22%29+and+%28self%3A%3Aa+or+self%3A%3Aimg%29%5D'
         17        DO_FCALL                                      0  $15     
         18      > FE_RESET_R                                       $16     $15, ->27
         19    > > FE_FETCH_R                                               $16, !4, ->27
   11    20    >   FETCH_OBJ_R                                      ~17     !4, 'ownerDocument'
         21        INIT_METHOD_CALL                                         ~17, 'saveHTML'
         22        SEND_VAR_EX                                              !4
         23        DO_FCALL                                      0  $18     
         24        CONCAT                                           ~19     $18, '%0A'
         25        ECHO                                                     ~19
   10    26      > JMP                                                      ->19
         27    >   FE_FREE                                                  $16
   12    28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
201.89 ms | 1082 KiB | 13 Q