3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<EOF <p>asdasd</p> <img src="img1.jpg" style="width: 180px;"> <p>asdasd</p> <img src="img2.jpg" style="width: 180px;"> <p>asdasd</p> <img src="img3.jpg" style="width: 180px;"> <p>asdasd</p> <img src="img4.jpg" style="width: 180px;"> EOF; $dom=new DOMDocument(); $dom->loadHTML($html); $imgs = $dom->getElementsByTagName("img"); foreach($imgs as $img){ $img->removeAttribute('style'); $img->setAttribute( 'src' , 'thumbnail.php?img=' . $img->getAttribute('src') ); } $dom->removeChild($dom->firstChild); # remove <html><body></body></html> $dom->replaceChild($dom->firstChild->firstChild->firstChild, $dom->firstChild); echo $dom->saveXML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 25
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 25
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/SZ8ag
function name:  (null)
number of ops:  45
compiled vars:  !0 = $html, !1 = $dom, !2 = $imgs, !3 = $img
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, '%0A%3Cp%3Easdasd%3C%2Fp%3E%0A%3Cimg+src%3D%22img1.jpg%22+style%3D%22width%3A+180px%3B%22%3E%0A%3Cp%3Easdasd%3C%2Fp%3E%0A%3Cimg+src%3D%22img2.jpg%22+style%3D%22width%3A+180px%3B%22%3E%0A%3Cp%3Easdasd%3C%2Fp%3E%0A%3Cimg+src%3D%22img3.jpg%22+style%3D%22width%3A+180px%3B%22%3E%0A%3Cp%3Easdasd%3C%2Fp%3E%0A%3Cimg+src%3D%22img4.jpg%22+style%3D%22width%3A+180px%3B%22%3E%0A'
   17     1        NEW                                              $5      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
   18     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   19     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              'img'
          9        DO_FCALL                                      0  $9      
         10        ASSIGN                                                   !2, $9
   20    11      > FE_RESET_R                                       $11     !2, ->25
         12    > > FE_FETCH_R                                               $11, !3, ->25
   21    13    >   INIT_METHOD_CALL                                         !3, 'removeAttribute'
         14        SEND_VAL_EX                                              'style'
         15        DO_FCALL                                      0          
   23    16        INIT_METHOD_CALL                                         !3, 'setAttribute'
         17        SEND_VAL_EX                                              'src'
         18        INIT_METHOD_CALL                                         !3, 'getAttribute'
         19        SEND_VAL_EX                                              'src'
         20        DO_FCALL                                      0  $13     
         21        CONCAT                                           ~14     'thumbnail.php%3Fimg%3D', $13
         22        SEND_VAL_EX                                              ~14
         23        DO_FCALL                                      0          
   20    24      > JMP                                                      ->12
         25    >   FE_FREE                                                  $11
   26    26        INIT_METHOD_CALL                                         !1, 'removeChild'
         27        CHECK_FUNC_ARG                                           
         28        FETCH_OBJ_FUNC_ARG                               $16     !1, 'firstChild'
         29        SEND_FUNC_ARG                                            $16
         30        DO_FCALL                                      0          
   29    31        INIT_METHOD_CALL                                         !1, 'replaceChild'
         32        CHECK_FUNC_ARG                                           
         33        FETCH_OBJ_FUNC_ARG                               $18     !1, 'firstChild'
         34        FETCH_OBJ_FUNC_ARG                               $19     $18, 'firstChild'
         35        FETCH_OBJ_FUNC_ARG                               $20     $19, 'firstChild'
         36        SEND_FUNC_ARG                                            $20
         37        CHECK_FUNC_ARG                                           
         38        FETCH_OBJ_FUNC_ARG                               $21     !1, 'firstChild'
         39        SEND_FUNC_ARG                                            $21
         40        DO_FCALL                                      0          
   31    41        INIT_METHOD_CALL                                         !1, 'saveXML'
         42        DO_FCALL                                      0  $23     
         43        ECHO                                                     $23
         44      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.94 ms | 1399 KiB | 13 Q