3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <div> <p> some text <a href="../plugins/re_records/somefile.php?page=something&id=345">find_me_1</a></p> <br> <a href="../plugins/re_records/somefile.php?page=something&id=99">find_me_2</a> <div> <div> <a href="example.com?page=something&id=55">don't even think about it!</a> <a href="../plugins/re_records/somefile.php?page=something&id=90210">find_me_3</a> </div> </div> </div> HTML; $hrefStartsWith = '../plugins/re_records/somefile.php?page=something&id='; $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($html, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED); $xpath = new DOMXPath($dom); foreach ($xpath->query("//a[starts-with(@href, '$hrefStartsWith')]") as $a) { $a->setAttribute('href', '/map/' . $a->nodeValue); } echo $dom->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 31
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/Ns7hk
function name:  (null)
number of ops:  36
compiled vars:  !0 = $html, !1 = $hrefStartsWith, !2 = $dom, !3 = $xpath, !4 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv%3E%0A++++%3Cp%3E+some+text+%3Ca+href%3D%22..%2Fplugins%2Fre_records%2Fsomefile.php%3Fpage%3Dsomething%26id%3D345%22%3Efind_me_1%3C%2Fa%3E%3C%2Fp%3E%0A++++%3Cbr%3E%0A++++%3Ca+href%3D%22..%2Fplugins%2Fre_records%2Fsomefile.php%3Fpage%3Dsomething%26id%3D99%22%3Efind_me_2%3C%2Fa%3E%0A++++%3Cdiv%3E%0A++++++++%3Cdiv%3E%0A++++++++++++%3Ca+href%3D%22example.com%3Fpage%3Dsomething%26id%3D55%22%3Edon%27t+even+think+about+it%21%3C%2Fa%3E%0A++++++++++++%3Ca+href%3D%22..%2Fplugins%2Fre_records%2Fsomefile.php%3Fpage%3Dsomething%26id%3D90210%22%3Efind_me_3%3C%2Fa%3E%0A++++++++%3C%2Fdiv%3E%0A++++%3C%2Fdiv%3E%0A%3C%2Fdiv%3E'
   17     1        ASSIGN                                                   !1, '..%2Fplugins%2Fre_records%2Fsomefile.php%3Fpage%3Dsomething%26id%3D'
   19     2        NEW                                              $7      'DOMDocument'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $7
   20     5        INIT_FCALL                                               'libxml_use_internal_errors'
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                                 
   21     8        INIT_METHOD_CALL                                         !2, 'loadHTML'
          9        SEND_VAR_EX                                              !0
         10        SEND_VAL_EX                                              8196
         11        DO_FCALL                                      0          
   22    12        NEW                                              $12     'DOMXPath'
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !3, $12
   23    16        INIT_METHOD_CALL                                         !3, 'query'
         17        ROPE_INIT                                     3  ~16     '%2F%2Fa%5Bstarts-with%28%40href%2C+%27'
         18        ROPE_ADD                                      1  ~16     ~16, !1
         19        ROPE_END                                      2  ~15     ~16, '%27%29%5D'
         20        SEND_VAL_EX                                              ~15
         21        DO_FCALL                                      0  $18     
         22      > FE_RESET_R                                       $19     $18, ->31
         23    > > FE_FETCH_R                                               $19, !4, ->31
   24    24    >   INIT_METHOD_CALL                                         !4, 'setAttribute'
         25        SEND_VAL_EX                                              'href'
         26        FETCH_OBJ_R                                      ~20     !4, 'nodeValue'
         27        CONCAT                                           ~21     '%2Fmap%2F', ~20
         28        SEND_VAL_EX                                              ~21
         29        DO_FCALL                                      0          
   23    30      > JMP                                                      ->23
         31    >   FE_FREE                                                  $19
   26    32        INIT_METHOD_CALL                                         !2, 'saveHTML'
         33        DO_FCALL                                      0  $23     
         34        ECHO                                                     $23
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
282.79 ms | 1015 KiB | 14 Q