3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html = <<<HTML <html> <head> <script type='text/javascript' src='/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script> <script language="JavaScript"> window.moveTo(0,0); window.resizeTo(screen.width,screen.height); </script> </head> </html> HTML; $workingUrl = 'https://www.example.com'; $dom = new DOMDocument; $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); foreach ($xpath->query("//script[@src]") as $node) { if (strpos($node->getAttribute('src'), 'http') !== 0) { $node->setAttribute('src', $workingUrl); } } echo $dom->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 29
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 29
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 28
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/rS0Ml
function name:  (null)
number of ops:  34
compiled vars:  !0 = $html, !1 = $workingUrl, !2 = $dom, !3 = $xpath, !4 = $node
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, '%3Chtml%3E%0A%3Chead%3E%0A%3Cscript+type%3D%27text%2Fjavascript%27+src%3D%27%2Fwp-includes%2Fjs%2Fjquery%2Fjquery.js%3Fver%3D1.8.3%27%3E%3C%2Fscript%3E%0A%3Cscript+language%3D%22JavaScript%22%3E%0Awindow.moveTo%280%2C0%29%3B%0Awindow.resizeTo%28screen.width%2Cscreen.height%29%3B%0A%3C%2Fscript%3E%0A%3C%2Fhead%3E%0A%3C%2Fhtml%3E'
   14     1        ASSIGN                                                       !1, 'https%3A%2F%2Fwww.example.com'
   16     2        NEW                                                  $7      'DOMDocument'
          3        DO_FCALL                                          0          
          4        ASSIGN                                                       !2, $7
   17     5        INIT_METHOD_CALL                                             !2, 'loadHTML'
          6        SEND_VAR_EX                                                  !0
          7        SEND_VAL_EX                                                  8196
          8        DO_FCALL                                          0          
   18     9        NEW                                                  $11     'DOMXPath'
         10        SEND_VAR_EX                                                  !2
         11        DO_FCALL                                          0          
         12        ASSIGN                                                       !3, $11
   19    13        INIT_METHOD_CALL                                             !3, 'query'
         14        SEND_VAL_EX                                                  '%2F%2Fscript%5B%40src%5D'
         15        DO_FCALL                                          0  $14     
         16      > FE_RESET_R                                           $15     $14, ->29
         17    > > FE_FETCH_R                                                   $15, !4, ->29
   20    18    >   INIT_METHOD_CALL                                             !4, 'getAttribute'
         19        SEND_VAL_EX                                                  'src'
         20        DO_FCALL                                          0  $16     
         21        FRAMELESS_ICALL_2                strpos              ~17     $16, 'http'
         22        IS_NOT_IDENTICAL                                             ~17, 0
         23      > JMPZ                                                         ~18, ->28
   21    24    >   INIT_METHOD_CALL                                             !4, 'setAttribute'
         25        SEND_VAL_EX                                                  'src'
         26        SEND_VAR_EX                                                  !1
         27        DO_FCALL                                          0          
   19    28    > > JMP                                                          ->17
         29    >   FE_FREE                                                      $15
   24    30        INIT_METHOD_CALL                                             !2, 'saveHTML'
         31        DO_FCALL                                          0  $20     
         32        ECHO                                                         $20
         33      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
151.27 ms | 2176 KiB | 13 Q