3v4l.org

run code in 300+ 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 = 32
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 32
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 31
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/rS0Ml
function name:  (null)
number of ops:  37
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, ->32
         17    > > FE_FETCH_R                                               $15, !4, ->32
   20    18    >   INIT_FCALL                                               'strpos'
         19        INIT_METHOD_CALL                                         !4, 'getAttribute'
         20        SEND_VAL_EX                                              'src'
         21        DO_FCALL                                      0  $16     
         22        SEND_VAR                                                 $16
         23        SEND_VAL                                                 'http'
         24        DO_ICALL                                         $17     
         25        IS_NOT_IDENTICAL                                         $17, 0
         26      > JMPZ                                                     ~18, ->31
   21    27    >   INIT_METHOD_CALL                                         !4, 'setAttribute'
         28        SEND_VAL_EX                                              'src'
         29        SEND_VAR_EX                                              !1
         30        DO_FCALL                                      0          
   19    31    > > JMP                                                      ->17
         32    >   FE_FREE                                                  $15
   24    33        INIT_METHOD_CALL                                         !2, 'saveHTML'
         34        DO_FCALL                                      0  $20     
         35        ECHO                                                     $20
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.2 ms | 1400 KiB | 15 Q