3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html = <<<HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content=""> <meta name="description" content=""> <meta name="author" content=""> <title></title> <link rel="apple-touch-icon" href=""> <link rel="shortcut icon" href=""> <!-- Stylesheets --> <link rel="stylesheet" href=""> <!-- Some Stylesheets --> <link rel="stylesheet" href=""> <!-- Some Stylesheets --> <link rel="stylesheet" href=""> <!-- Some Stylesheets --> <!-- Scripts --> <script src=""></script> </head> <body class=""> <nav class="nav1" role="navigation"> <!-- Some HTML --> </nav> <div class="menubar1"> <!-- Some HTML --> </div> <div class="menubar2"> <div> <div> <ul> <li></li> </ul> </div> </div> <!-- Some HTML --> </div> <!-- ========================================================= --> <!-- ========================================================= --> <!-- PAGE CONTENTS --> <!-- ========================================================= --> <!-- ========================================================= --> <!-- Footer --> <footer class="site-footer"> <!-- Some HTML --> </footer> <script src=""></script> <!-- Some Script Tags --> <script src=""></script> <!-- Some Script Tags --> <script src=""></script> <!-- Some Script Tags --> <script src=""></script> <!-- Some Script Tags --> <!-- Page --> <!-- Google Analytics --> <script> /* Some Scripts */ </script> </body> </html> HTML; libxml_use_internal_errors(true); $doc = new \DOMDocument(); $doc->loadHTML($html); $menubar2_inner_div_count = (new \DOMXPath($doc))->query('//div[@class="menubar2"]//div')->length; $html = preg_replace('/^.*?<div class="menubar2">' . str_repeat('.*?<\/div>', $menubar2_inner_div_count + 1) . '/s', '<!-- Header -->' . PHP_EOL . '<?php include_once "include/header.php" ?>', $html); $html = preg_replace('/<footer class="site-footer">.*?<\/html>/s', '<?php include_once "include/footer.php" ?>', $html); $html = preg_replace('/^ {8}/m', '', $html); echo $html;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/G3HbK
function name:  (null)
number of ops:  36
compiled vars:  !0 = $html, !1 = $doc, !2 = $menubar2_inner_div_count
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%3C%21DOCTYPE+html%3E%0A%3Chtml+lang%3D%22en%22%3E%0A++++%3Chead%3E%0A++++++++%3Cmeta+charset%3D%22utf-8%22%3E%0A++++++++%3Cmeta+http-equiv%3D%22X-UA-Compatible%22+content%3D%22IE%3Dedge%22%3E%0A++++++++%3Cmeta+name%3D%22viewport%22+content%3D%22%22%3E%0A++++++++%3Cmeta+name%3D%22description%22+content%3D%22%22%3E%0A++++++++%3Cmeta+name%3D%22author%22+content%3D%22%22%3E%0A%0A++++++++%3Ctitle%3E%3C%2Ftitle%3E%0A%0A++++++++%3Clink+rel%3D%22apple-touch-icon%22+href%3D%22%22%3E%0A++++++++%3Clink+rel%3D%22shortcut+icon%22+href%3D%22%22%3E%0A%0A++++++++%3C%21--+Stylesheets+--%3E%0A++++++++%3Clink+rel%3D%22stylesheet%22+href%3D%22%22%3E+%3C%21--+Some+Stylesheets+--%3E%0A++++++++%3Clink+rel%3D%22stylesheet%22+href%3D%22%22%3E+%3C%21--+Some+Stylesheets+--%3E%0A++++++++%3Clink+rel%3D%22stylesheet%22+href%3D%22%22%3E+%3C%21--+Some+Stylesheets+--%3E%0A%0A++++++++%3C%21--+Scripts+--%3E%0A++++++++%3Cscript+src%3D%22%22%3E%3C%2Fscript%3E%0A++++%3C%2Fhead%3E%0A++++%3Cbody+class%3D%22%22%3E%0A++++++++%3Cnav+class%3D%22nav1%22+role%3D%22navigation%22%3E%0A++++++++++++%3C%21--+Some+HTML+--%3E%0A++++++++%3C%2Fnav%3E%0A++++++++%3Cdiv+class%3D%22menubar1%22%3E%0A++++++++++++%3C%21--+Some+HTML+--%3E%0A++++++++%3C%2Fdiv%3E%0A++++++++%3Cdiv+class%3D%22menubar2%22%3E%0A++++++++++++%3Cdiv%3E%0A++++++++++++++++%3Cdiv%3E%0A++++++++++++++++++++%3Cul%3E%0A++++++++++++++++++++++++%3Cli%3E%3C%2Fli%3E%0A++++++++++++++++++++%3C%2Ful%3E%0A++++++++++++++++%3C%2Fdiv%3E%0A++++++++++++%3C%2Fdiv%3E%0A++++++++++++%3C%21--+Some+HTML+--%3E%0A++++++++%3C%2Fdiv%3E%0A%0A++++++++%3C%21--+%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D+--%3E%0A++++++++%3C%21--+%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D+--%3E%0A%0A++++++++%3C%21--+PAGE+CONTENTS+--%3E%0A%0A++++++++%3C%21--+%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D+--%3E%0A++++++++%3C%21--+%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D+--%3E%0A%0A++++++++%3C%21--+Footer+--%3E%0A++++++++%3Cfooter+class%3D%22site-footer%22%3E%0A++++++++++++%3C%21--+Some+HTML+--%3E%0A++++++++%3C%2Ffooter%3E%0A%0A++++++++%3Cscript+src%3D%22%22%3E%3C%2Fscript%3E+%3C%21--+Some+Script+Tags+--%3E%0A++++++++%3Cscript+src%3D%22%22%3E%3C%2Fscript%3E+%3C%21--+Some+Script+Tags+--%3E%0A++++++++%3Cscript+src%3D%22%22%3E%3C%2Fscript%3E+%3C%21--+Some+Script+Tags+--%3E%0A++++++++%3Cscript+src%3D%22%22%3E%3C%2Fscript%3E+%3C%21--+Some+Script+Tags+--%3E%0A%0A++++++++%3C%21--+Page+--%3E%0A%0A++++++++%3C%21--+Google+Analytics+--%3E%0A++++++++%3Cscript%3E%0A++++++++++++%2F%2A+Some+Scripts+%2A%2F%0A++++++++%3C%2Fscript%3E%0A++++%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   72     1        INIT_FCALL                                                   'libxml_use_internal_errors'
          2        SEND_VAL                                                     <true>
          3        DO_ICALL                                                     
   73     4        NEW                                                  $5      'DOMDocument'
          5        DO_FCALL                                          0          
          6        ASSIGN                                                       !1, $5
   74     7        INIT_METHOD_CALL                                             !1, 'loadHTML'
          8        SEND_VAR_EX                                                  !0
          9        DO_FCALL                                          0          
   75    10        NEW                                                  $9      'DOMXPath'
         11        SEND_VAR_EX                                                  !1
         12        DO_FCALL                                          0          
         13        INIT_METHOD_CALL                                             $9, 'query'
         14        SEND_VAL_EX                                                  '%2F%2Fdiv%5B%40class%3D%22menubar2%22%5D%2F%2Fdiv'
         15        DO_FCALL                                          0  $11     
         16        FETCH_OBJ_R                                          ~12     $11, 'length'
         17        ASSIGN                                                       !2, ~12
   77    18        INIT_FCALL                                                   'str_repeat'
         19        SEND_VAL                                                     '.%2A%3F%3C%5C%2Fdiv%3E'
         20        ADD                                                  ~14     !2, 1
         21        SEND_VAL                                                     ~14
         22        DO_ICALL                                             $15     
         23        CONCAT                                               ~16     '%2F%5E.%2A%3F%3Cdiv+class%3D%22menubar2%22%3E', $15
         24        CONCAT                                               ~17     ~16, '%2Fs'
         25        FRAMELESS_ICALL_3                preg_replace        ~18     ~17, '%3C%21--+Header+--%3E%0A%3C%3Fphp+include_once+%22include%2Fheader.php%22+%3F%3E'
         26        OP_DATA                                                      !0
         27        ASSIGN                                                       !0, ~18
   78    28        FRAMELESS_ICALL_3                preg_replace        ~20     '%2F%3Cfooter+class%3D%22site-footer%22%3E.%2A%3F%3C%5C%2Fhtml%3E%2Fs', '%3C%3Fphp+include_once+%22include%2Ffooter.php%22+%3F%3E'
         29        OP_DATA                                                      !0
         30        ASSIGN                                                       !0, ~20
   79    31        FRAMELESS_ICALL_3                preg_replace        ~22     '%2F%5E+%7B8%7D%2Fm', ''
         32        OP_DATA                                                      !0
         33        ASSIGN                                                       !0, ~22
   81    34        ECHO                                                         !0
   82    35      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.79 ms | 2203 KiB | 15 Q