3v4l.org

run code in 500+ PHP versions simultaneously
<?php $content = <<<DATA <body> <div class="entry-content"> <p><img src="https://picsum.photos/200/300" alt="" width="3264" height="2448" class="alignleft size-full wp-image-24" srcset="http://localhost/wp/wp-content/uploads/2018/08/image-1356510220.jpg 3264w, http://localhost/wp/wp-content/uploads/2018/08/image-1356510220-300x225.jpg 300w, http://localhost/wp/wp-content/uploads/2018/08/image-1356510220-768x576.jpg 768w, http://localhost/wp/wp-content/uploads/2018/08/image-1356510220-1024x768.jpg 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p> <p>Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet</p> <p><img src="https://picsum.photos/200/300" alt="" width="3264" height="2448" class="alignleft size-full wp-image-24" srcset="http://localhost/wp/wp-content/uploads/2018/08/image-1356510220.jpg 3264w, http://localhost/wp/wp-content/uploads/2018/08/image-1356510220-300x225.jpg 300w, http://localhost/wp/wp-content/uploads/2018/08/image-1356510220-768x576.jpg 768w, http://localhost/wp/wp-content/uploads/2018/08/image-1356510220-1024x768.jpg 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px" /></p> </div> </body> DATA; libxml_use_internal_errors(true); $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadHTML($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $keyword = "HELLO"; $images = $dom->getElementsByTagName('img'); foreach ( $images as $image) { if (empty($image->getAttribute("alt"))) { $image->setAttribute('alt', $keyword); } } $content = $dom->saveHTML(); return $content;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 30
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 30
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 29
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/DvE4U
function name:  (null)
number of ops:  36
compiled vars:  !0 = $content, !1 = $dom, !2 = $keyword, !3 = $images, !4 = $image
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    1     0  E >   ASSIGN                                                       !0, '%3Cbody%3E%0A%3Cdiv+class%3D%22entry-content%22%3E%0A%09%3Cp%3E%3Cimg+src%3D%22https%3A%2F%2Fpicsum.photos%2F200%2F300%22+alt%3D%22%22+width%3D%223264%22+height%3D%222448%22+class%3D%22alignleft+size-full+wp-image-24%22+srcset%3D%22http%3A%2F%2Flocalhost%2Fwp%2Fwp-content%2Fuploads%2F2018%2F08%2Fimage-1356510220.jpg+3264w%2C+http%3A%2F%2Flocalhost%2Fwp%2Fwp-content%2Fuploads%2F2018%2F08%2Fimage-1356510220-300x225.jpg+300w%2C+http%3A%2F%2Flocalhost%2Fwp%2Fwp-content%2Fuploads%2F2018%2F08%2Fimage-1356510220-768x576.jpg+768w%2C+http%3A%2F%2Flocalhost%2Fwp%2Fwp-content%2Fuploads%2F2018%2F08%2Fimage-1356510220-1024x768.jpg+1024w%22+sizes%3D%22%28max-width%3A+767px%29+89vw%2C+%28max-width%3A+1000px%29+54vw%2C+%28max-width%3A+1071px%29+543px%2C+580px%22+%2F%3E%3C%2Fp%3E%0A%09%0A%09%3Cp%3ELorem+ipsum+dolor+sit+amet+Lorem+ipsum+dolor+sit+amet+Lorem+ipsum+dolor+sit+amet%3C%2Fp%3E%0A%09%0A%09%3Cp%3E%3Cimg+src%3D%22https%3A%2F%2Fpicsum.photos%2F200%2F300%22+alt%3D%22%22+width%3D%223264%22+height%3D%222448%22+class%3D%22alignleft+size-full+wp-image-24%22+srcset%3D%22http%3A%2F%2Flocalhost%2Fwp%2Fwp-content%2Fuploads%2F2018%2F08%2Fimage-1356510220.jpg+3264w%2C+http%3A%2F%2Flocalhost%2Fwp%2Fwp-content%2Fuploads%2F2018%2F08%2Fimage-1356510220-300x225.jpg+300w%2C+http%3A%2F%2Flocalhost%2Fwp%2Fwp-content%2Fuploads%2F2018%2F08%2Fimage-1356510220-768x576.jpg+768w%2C+http%3A%2F%2Flocalhost%2Fwp%2Fwp-content%2Fuploads%2F2018%2F08%2Fimage-1356510220-1024x768.jpg+1024w%22+sizes%3D%22%28max-width%3A+767px%29+89vw%2C+%28max-width%3A+1000px%29+54vw%2C+%28max-width%3A+1071px%29+543px%2C+580px%22+%2F%3E%3C%2Fp%3E%0A%3C%2Fdiv%3E%0A%3C%2Fbody%3E'
   13     1        INIT_FCALL                                                   'libxml_use_internal_errors'
          2        SEND_VAL                                                     <true>
          3        DO_ICALL                                                     
   14     4        NEW                                                  $7      'DOMDocument'
          5        SEND_VAL_EX                                                  '1.0'
          6        SEND_VAL_EX                                                  'UTF-8'
          7        DO_FCALL                                          0          
          8        ASSIGN                                                       !1, $7
   15     9        INIT_METHOD_CALL                                             !1, 'loadHTML'
         10        SEND_VAR_EX                                                  !0
         11        SEND_VAL_EX                                                  8196
         12        DO_FCALL                                          0          
   17    13        ASSIGN                                                       !2, 'HELLO'
   18    14        INIT_METHOD_CALL                                             !1, 'getElementsByTagName'
         15        SEND_VAL_EX                                                  'img'
         16        DO_FCALL                                          0  $12     
         17        ASSIGN                                                       !3, $12
   20    18      > FE_RESET_R                                           $14     !3, ->30
         19    > > FE_FETCH_R                                                   $14, !4, ->30
   21    20    >   INIT_METHOD_CALL                                             !4, 'getAttribute'
         21        SEND_VAL_EX                                                  'alt'
         22        DO_FCALL                                          0  $15     
         23        BOOL_NOT                                             ~16     $15
         24      > JMPZ                                                         ~16, ->29
   22    25    >   INIT_METHOD_CALL                                             !4, 'setAttribute'
         26        SEND_VAL_EX                                                  'alt'
         27        SEND_VAR_EX                                                  !2
         28        DO_FCALL                                          0          
   20    29    > > JMP                                                          ->19
         30    >   FE_FREE                                                      $14
   26    31        INIT_METHOD_CALL                                             !1, 'saveHTML'
         32        DO_FCALL                                          0  $18     
         33        ASSIGN                                                       !0, $18
   28    34      > RETURN                                                       !0
   29    35*     > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.8 ms | 2036 KiB | 14 Q