3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<img scr1="xxxx.jpg" src="aaaa.jpg" other_attributes="some_values" />'; $dom = new DOMDocument; $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($dom); $images = $xpath->query("//img"); foreach ($images as $image) { if ($image->hasAttribute('scr1')) { $src1 = $image->getAttribute('scr1'); $image->removeAttribute('scr1'); $image->setAttribute('src', $src1); } } echo $dom->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 34
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 34
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 33
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 33
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/524Al
function name:  (null)
number of ops:  39
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $images, !4 = $image, !5 = $src1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cimg+scr1%3D%22xxxx.jpg%22+src%3D%22aaaa.jpg%22+other_attributes%3D%22some_values%22+%2F%3E'
    4     1        NEW                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
    5     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              8196
          7        DO_FCALL                                      0          
    6     8        NEW                                              $11     'DOMXPath'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $11
    8    12        INIT_METHOD_CALL                                         !2, 'query'
         13        SEND_VAL_EX                                              '%2F%2Fimg'
         14        DO_FCALL                                      0  $14     
         15        ASSIGN                                                   !3, $14
    9    16      > FE_RESET_R                                       $16     !3, ->34
         17    > > FE_FETCH_R                                               $16, !4, ->34
   10    18    >   INIT_METHOD_CALL                                         !4, 'hasAttribute'
         19        SEND_VAL_EX                                              'scr1'
         20        DO_FCALL                                      0  $17     
         21      > JMPZ                                                     $17, ->33
   11    22    >   INIT_METHOD_CALL                                         !4, 'getAttribute'
         23        SEND_VAL_EX                                              'scr1'
         24        DO_FCALL                                      0  $18     
         25        ASSIGN                                                   !5, $18
   12    26        INIT_METHOD_CALL                                         !4, 'removeAttribute'
         27        SEND_VAL_EX                                              'scr1'
         28        DO_FCALL                                      0          
   13    29        INIT_METHOD_CALL                                         !4, 'setAttribute'
         30        SEND_VAL_EX                                              'src'
         31        SEND_VAR_EX                                              !5
         32        DO_FCALL                                      0          
    9    33    > > JMP                                                      ->17
         34    >   FE_FREE                                                  $16
   17    35        INIT_METHOD_CALL                                         !1, 'saveHTML'
         36        DO_FCALL                                      0  $22     
         37        ECHO                                                     $22
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
134.66 ms | 1012 KiB | 13 Q