3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = ' <?xml version="1.0" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <body> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vitae ex a arcu tempus tincidunt ac non nulla. Aliquam erat volutpat. Mauris nunc ex, imperdi ▶ <figure class="image"> <img src="/storage/12/articles/pictures/body_1574785274232_0d61f8370cad1d412f80b84d143e1257.jpeg"/> <figcaption>caption zzzzz</figcaption> </figure> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vitae ex a arcu tempus tincidunt ac non nulla. Aliquam erat volutpat. Mauris nunc ex, imperdi ▶ <p>&#xA0;</p> </body> </html> '; $dom_err = libxml_use_internal_errors(true); $dom = new \DOMDocument('1.0', 'utf-8'); $dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED); $xpath = new \DOMXPath($dom); foreach ($xpath->query("//figure") as $img) { $p = $dom->createElement("p"); $p->setAttribute('style', 'text-align:center'); $img->parentNode->replaceChild($p, $img); $p->appendChild($img); } echo $dom->saveHTML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 45
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 45
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
filename:       /in/e32JJ
function name:  (null)
number of ops:  50
compiled vars:  !0 = $html, !1 = $dom_err, !2 = $dom, !3 = $xpath, !4 = $img, !5 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%0A++++++++++%3C%3Fxml+version%3D%221.0%22+standalone%3D%22yes%22%3F%3E%0A++++++++++%3C%21DOCTYPE+html+PUBLIC+%22-%2F%2FW3C%2F%2FDTD+HTML+4.0+Transitional%2F%2FEN%22+%22http%3A%2F%2Fwww.w3.org%2FTR%2FREC-html40%2Floose.dtd%22%3E%0A++++++++++%3Chtml%3E%0A++++++++++++%3Cbody%3E%0A++++++++++++++%3Cp%3ELorem+ipsum+dolor+sit+amet%2C+consectetur+adipiscing+elit.+Ut+vitae+ex+a+arcu+tempus+tincidunt+ac+non+nulla.+Aliquam+erat+volutpat.+Mauris+nunc+ex%2C+imperdi+%E2%96%B6%0A++++++++++++++%3Cfigure+class%3D%22image%22%3E%0A++++++++++++++++%3Cimg+src%3D%22%2Fstorage%2F12%2Farticles%2Fpictures%2Fbody_1574785274232_0d61f8370cad1d412f80b84d143e1257.jpeg%22%2F%3E%0A++++++++++++++++%3Cfigcaption%3Ecaption+zzzzz%3C%2Ffigcaption%3E%0A++++++++++++++%3C%2Ffigure%3E%0A++++++++++++++%3Cp%3ELorem+ipsum+dolor+sit+amet%2C+consectetur+adipiscing+elit.+Ut+vitae+ex+a+arcu+tempus+tincidunt+ac+non+nulla.+Aliquam+erat+volutpat.+Mauris+nunc+ex%2C+imperdi+%E2%96%B6%0A++++++++++++++%3Cp%3E%26%23xA0%3B%3C%2Fp%3E%0A++++++++++++%3C%2Fbody%3E%0A++++++++++%3C%2Fhtml%3E%0A'
   18     1        INIT_FCALL                                               'libxml_use_internal_errors'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !1, $7
   19     5        NEW                                              $9      'DOMDocument'
          6        SEND_VAL_EX                                              '1.0'
          7        SEND_VAL_EX                                              'utf-8'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !2, $9
   20    10        INIT_METHOD_CALL                                         !2, 'loadHTML'
         11        INIT_FCALL                                               'mb_convert_encoding'
         12        SEND_VAR                                                 !0
         13        SEND_VAL                                                 'HTML-ENTITIES'
         14        SEND_VAL                                                 'UTF-8'
         15        DO_ICALL                                         $12     
         16        SEND_VAR_NO_REF_EX                                       $12
         17        SEND_VAL_EX                                              8192
         18        DO_FCALL                                      0          
   21    19        NEW                                              $14     'DOMXPath'
         20        SEND_VAR_EX                                              !2
         21        DO_FCALL                                      0          
         22        ASSIGN                                                   !3, $14
   22    23        INIT_METHOD_CALL                                         !3, 'query'
         24        SEND_VAL_EX                                              '%2F%2Ffigure'
         25        DO_FCALL                                      0  $17     
         26      > FE_RESET_R                                       $18     $17, ->45
         27    > > FE_FETCH_R                                               $18, !4, ->45
   24    28    >   INIT_METHOD_CALL                                         !2, 'createElement'
         29        SEND_VAL_EX                                              'p'
         30        DO_FCALL                                      0  $19     
         31        ASSIGN                                                   !5, $19
   25    32        INIT_METHOD_CALL                                         !5, 'setAttribute'
         33        SEND_VAL_EX                                              'style'
         34        SEND_VAL_EX                                              'text-align%3Acenter'
         35        DO_FCALL                                      0          
   26    36        FETCH_OBJ_R                                      ~22     !4, 'parentNode'
         37        INIT_METHOD_CALL                                         ~22, 'replaceChild'
         38        SEND_VAR_EX                                              !5
         39        SEND_VAR_EX                                              !4
         40        DO_FCALL                                      0          
   27    41        INIT_METHOD_CALL                                         !5, 'appendChild'
         42        SEND_VAR_EX                                              !4
         43        DO_FCALL                                      0          
   22    44      > JMP                                                      ->27
         45    >   FE_FREE                                                  $18
   29    46        INIT_METHOD_CALL                                         !2, 'saveHTML'
         47        DO_FCALL                                      0  $25     
         48        ECHO                                                     $25
         49      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.38 ms | 1008 KiB | 15 Q