3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<EOD <h1>Escape HTML or Other Programming tags</h1> <p>This must be rendered without any problem</p> <p> <code style="display:block;background:rgb(230,230,230);padding:2%"> <h4>Show this title in HTML</h4> <p>This paragraph must be in <strong>HTML</strong> and this <a href="">Link</a> too !</p> <?php echo "Display this PHP code!"; ?> <script> alert("Don't pop-up please!"); </script> </code> <a href="">Link rendered</a> </p> EOD; $dom = new DOMDocument; $dom->loadHTML($html); $xpath = new DOMXPath($dom); foreach ($xpath->query("//code") as $codeNode) { $codeContent = ''; while ($codeNode->hasChildNodes()) { $codeChild = $codeNode->firstChild; $codeContent .= $dom->saveHTML($codeChild); $codeNode->removeChild($codeChild); } $codeNode->textContent = $codeContent; } $texte = $dom->saveHTML(); echo $texte;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 33
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 33
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 18
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 18
Branch analysis from position: 30
Branch analysis from position: 18
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/2hjIs
function name:  (null)
number of ops:  39
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $codeNode, !4 = $codeContent, !5 = $codeChild, !6 = $texte
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '++++%3Ch1%3EEscape+HTML+or+Other+Programming+tags%3C%2Fh1%3E%0A++++%3Cp%3EThis+must+be+rendered+without+any+problem%3C%2Fp%3E%0A++++%3Cp%3E%0A++++%3Ccode+style%3D%22display%3Ablock%3Bbackground%3Argb%28230%2C230%2C230%29%3Bpadding%3A2%25%22%3E%0A++++++++%3Ch4%3EShow+this+title+in+HTML%3C%2Fh4%3E%0A++++++++%3Cp%3EThis+paragraph+must+be+in+%3Cstrong%3EHTML%3C%2Fstrong%3E+and+this+%3Ca+href%3D%22%22%3ELink%3C%2Fa%3E+too+%21%3C%2Fp%3E%0A++++++++%3C%3Fphp+%0A++++++++++++echo+%22Display+this+PHP+code%21%22%3B%0A++++++++%3F%3E%0A++++++++%3Cscript%3E%0A++++++++++++alert%28%22Don%27t+pop-up+please%21%22%29%3B%0A++++++++%3C%2Fscript%3E%0A++++%3C%2Fcode%3E%0A++++%3Ca+href%3D%22%22%3ELink+rendered%3C%2Fa%3E%0A++++%3C%2Fp%3E+'
   21     1        NEW                                              $8      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $8
   22     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   23     7        NEW                                              $12     'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $12
   25    11        INIT_METHOD_CALL                                         !2, 'query'
         12        SEND_VAL_EX                                              '%2F%2Fcode'
         13        DO_FCALL                                      0  $15     
         14      > FE_RESET_R                                       $16     $15, ->33
         15    > > FE_FETCH_R                                               $16, !3, ->33
   26    16    >   ASSIGN                                                   !4, ''
   28    17      > JMP                                                      ->27
   29    18    >   FETCH_OBJ_R                                      ~18     !3, 'firstChild'
         19        ASSIGN                                                   !5, ~18
   30    20        INIT_METHOD_CALL                                         !1, 'saveHTML'
         21        SEND_VAR_EX                                              !5
         22        DO_FCALL                                      0  $20     
         23        ASSIGN_OP                                     8          !4, $20
   31    24        INIT_METHOD_CALL                                         !3, 'removeChild'
         25        SEND_VAR_EX                                              !5
         26        DO_FCALL                                      0          
   28    27    >   INIT_METHOD_CALL                                         !3, 'hasChildNodes'
         28        DO_FCALL                                      0  $23     
         29      > JMPNZ                                                    $23, ->18
   34    30    >   ASSIGN_OBJ                                               !3, 'textContent'
         31        OP_DATA                                                  !4
   25    32      > JMP                                                      ->15
         33    >   FE_FREE                                                  $16
   37    34        INIT_METHOD_CALL                                         !1, 'saveHTML'
         35        DO_FCALL                                      0  $25     
         36        ASSIGN                                                   !6, $25
   38    37        ECHO                                                     !6
   39    38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.94 ms | 1399 KiB | 13 Q