3v4l.org

run code in 300+ PHP versions simultaneously
<?php foreach(array('<p><span><a href=""><img src="some.jpg"></a></span></p>', '<p>Text text text<span><a href=""><img src="some.jpg"></a></span></p>', '<p><span>Text text text<a href=""><img src="some.jpg"></a></span></p>') as $html) { $dom=new DOMDocument(); $dom->loadHTML($html); $xpath=new DOMXPath($dom); var_dump($xpath->query('//img[string-length(//text())<=0]')->length); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 1, Position 2 = 20
Branch analysis from position: 1
2 jumps found. (Code = 78) Position 1 = 2, Position 2 = 20
Branch analysis from position: 2
1 jumps found. (Code = 42) Position 1 = 1
Branch analysis from position: 1
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/I74FN
function name:  (null)
number of ops:  22
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E > > FE_RESET_R                                       $3      <array>, ->20
          1    > > FE_FETCH_R                                               $3, !0, ->20
    6     2    >   NEW                                              $4      'DOMDocument'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $4
    7     5        INIT_METHOD_CALL                                         !1, 'loadHTML'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
    8     8        NEW                                              $8      'DOMXPath'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $8
    9    12        INIT_FCALL                                               'var_dump'
         13        INIT_METHOD_CALL                                         !2, 'query'
         14        SEND_VAL_EX                                              '%2F%2Fimg%5Bstring-length%28%2F%2Ftext%28%29%29%3C%3D0%5D'
         15        DO_FCALL                                      0  $11     
         16        FETCH_OBJ_R                                      ~12     $11, 'length'
         17        SEND_VAL                                                 ~12
         18        DO_ICALL                                                 
    2    19      > JMP                                                      ->1
         20    >   FE_FREE                                                  $3
   10    21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.23 ms | 1395 KiB | 15 Q