3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<'HTML' <!DOCTYPE html> <html> <head> <script> let a=123; // comment // second comment let b='https://www.bbc.co.uk'; // This is a comment /* This is another comment */ // The following is not a comment var src="//google.com"; toolbar.querySelector('.toolbar-format_italic').addEventListener('click', function () { doInsertAtCursor(textarea, "///", "///"); doRefreshPreview(textarea); }.bind(_self)); /* Comment */ Prism.languages.javascript = Prism.languages.extend( regex: { pattern: RegExp("((?:^|[^$\\w\\xA0-\\uFFFF.\"'\\])\\s]|\\b(?:return|yield))\\s*)/(?:(?:\\[(?:[^\\]\\\\\r\n]|\\\\.)*\\]|\\\\.|[^/\\\\\\[\r\n])+/[dgimyus]{0,7}|(?:\\[(?:[^[\\]\\\\\r\n]|\\\\.|\\[(?:[^[\\]\\\\\r\n]|\\\\.|\\[(?:[^[\\]\\\\\r\n]|\\\\.)*\\])*\\])*\\]|\\\\.|[^/\\\\\\[\r\n])+/[dgimyus]{0,7}v[dgimyus]{0,7})(?=(?:\\s|/\\*(?:[^*]|\\*(?!/))*\\*/)*(?:$|[\r\n,.;:})\\]]|//))"), lookbehind: !0, greedy: !0, inside: { "regex-source": { pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/, lookbehind: !0, alias: "language-regex", inside: Prism.languages.regex }, "regex-delimiter": /^\/|\/$/, "regex-flags": /^[a-z]+$/ } }); text = text.replace(/\/\/\/(.*?)\/\/\//g, "<em>$1<\/em>"); </script> </head> <body> </body> </html> HTML; libxml_use_internal_errors(true); $dom = new DOMDocument; $dom->loadHTML($html); $scriptNodes = $dom->getElementsByTagName('script'); $pattern = <<<'EOD' ~ (?(DEFINE) (?<squoted> ' [^'\n\\]*+ (?: \\. [^'\n\\]* )*+ ' ) (?<dquoted> " [^"\n\\]*+ (?: \\. [^"\n\\]* )*+ " ) (?<tquoted> ` [^`\\]*+ (?s: \\. [^`\\]*)*+ ` ) (?<quoted> \g<squoted> | \g<dquoted> | \g<tquoted> ) (?<scomment> // \N* ) (?<mcomment> /\* [^*]*+ (?: \*+ (?!/) [^*]* )*+ \*/ ) (?<comment> \g<scomment> | \g<mcomment> ) (?<pattern> / (?=[^\n/*]) [^\n/\\]*+ (?>\\.[^\n/\\]*)* / [gimuy]* ) ) (?=[[(:,=/"'`]) (?| \g<quoted> (*SKIP)(*FAIL) | ( [[(:,=] \s* ) (*SKIP) (?: \g<comment> \s* )*+ ( \g<pattern> ) | ( \g<pattern> \s* ) (?: \g<comment> \s* )*+ ( \. \s* ) (?:\g<comment> \s* )*+ ([A-Za-z_]\w*) | \g<comment> ) ~x EOD; foreach ($scriptNodes as $scriptNode) { $scriptNode->nodeValue = preg_replace($pattern, '$9${10}${11}', $scriptNode->nodeValue); } $html = $dom->saveHTML(); echo $html; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 26
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/vtMHj
function name:  (null)
number of ops:  32
compiled vars:  !0 = $html, !1 = $dom, !2 = $scriptNodes, !3 = $pattern, !4 = $scriptNode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3C%21DOCTYPE+html%3E%0A%3Chtml%3E%0A++++%3Chead%3E%0A++++++++%3Cscript%3E%0A%0Alet+a%3D123%3B+%2F%2F+comment+%2F%2F+second+comment%0Alet+b%3D%27https%3A%2F%2Fwww.bbc.co.uk%27%3B%0A%0A%0A%2F%2F+This+is+a+comment%0A%2F%2A+This+is+another+comment+%2A%2F%0A%0A%2F%2F+The+following+is+not+a+comment%0Avar+src%3D%22%2F%2Fgoogle.com%22%3B+%0A%0A%0Atoolbar.querySelector%28%27.toolbar-format_italic%27%29.addEventListener%28%27click%27%2C+function+%28%29+%7B%0A++++++++++++++++doInsertAtCursor%28textarea%2C+%22%2F%2F%2F%22%2C+%22%2F%2F%2F%22%29%3B%0A++++++++++++++++doRefreshPreview%28textarea%29%3B%0A++++++++++++%7D.bind%28_self%29%29%3B+%2F%2A+Comment+%2A%2F%0A+Prism.languages.javascript+%3D+Prism.languages.extend%28++++++++++%0Aregex%3A+%7B%0A++++++++pattern%3A+RegExp%28%22%28%28%3F%3A%5E%7C%5B%5E%24%5C%5Cw%5C%5CxA0-%5C%5CuFFFF.%5C%22%27%5C%5C%5D%29%5C%5Cs%5D%7C%5C%5Cb%28%3F%3Areturn%7Cyield%29%29%5C%5Cs%2A%29%2F%28%3F%3A%28%3F%3A%5C%5C%5B%28%3F%3A%5B%5E%5C%5C%5D%5C%5C%5C%5C%5Cr%5Cn%5D%7C%5C%5C%5C%5C.%29%2A%5C%5C%5D%7C%5C%5C%5C%5C.%7C%5B%5E%2F%5C%5C%5C%5C%5C%5C%5B%5Cr%5Cn%5D%29%2B%2F%5Bdgimyus%5D%7B0%2C7%7D%7C%28%3F%3A%5C%5C%5B%28%3F%3A%5B%5E%5B%5C%5C%5D%5C%5C%5C%5C%5Cr%5Cn%5D%7C%5C%5C%5C%5C.%7C%5C%5C%5B%28%3F%3A%5B%5E%5B%5C%5C%5D%5C%5C%5C%5C%5Cr%5Cn%5D%7C%5C%5C%5C%5C.%7C%5C%5C%5B%28%3F%3A%5B%5E%5B%5C%5C%5D%5C%5C%5C%5C%5Cr%5Cn%5D%7C%5C%5C%5C%5C.%29%2A%5C%5C%5D%29%2A%5C%5C%5D%29%2A%5C%5C%5D%7C%5C%5C%5C%5C.%7C%5B%5E%2F%5C%5C%5C%5C%5C%5C%5B%5Cr%5Cn%5D%29%2B%2F%5Bdgimyus%5D%7B0%2C7%7Dv%5Bdgimyus%5D%7B0%2C7%7D%29%28%3F%3D%28%3F%3A%5C%5Cs%7C%2F%5C%5C%2A%28%3F%3A%5B%5E%2A%5D%7C%5C%5C%2A%28%3F%21%2F%29%29%2A%5C%5C%2A%2F%29%2A%28%3F%3A%24%7C%5B%5Cr%5Cn%2C.%3B%3A%7D%29%5C%5C%5D%5D%7C%2F%2F%29%29%22%29%2C%0A++++++++lookbehind%3A+%210%2C%0A++++++++greedy%3A+%210%2C%0A++++++++inside%3A+%7B%0A++++++++++++%22regex-source%22%3A+%7B%0A++++++++++++++++pattern%3A+%2F%5E%28%5C%2F%29%5B%5Cs%5CS%5D%2B%28%3F%3D%5C%2F%5Ba-z%5D%2A%24%29%2F%2C%0A++++++++++++++++lookbehind%3A+%210%2C%0A++++++++++++++++alias%3A+%22language-regex%22%2C%0A++++++++++++++++inside%3A+Prism.languages.regex%0A++++++++++++%7D%2C+%22regex-delimiter%22%3A+%2F%5E%5C%2F%7C%5C%2F%24%2F%2C+%22regex-flags%22%3A+%2F%5E%5Ba-z%5D%2B%24%2F%0A++++++++%7D%0A++++%7D%29%3B%0A%0A++++text+%3D+text.replace%28%2F%5C%2F%5C%2F%5C%2F%28.%2A%3F%29%5C%2F%5C%2F%5C%2F%2Fg%2C+%22%3Cem%3E%241%3C%5C%2Fem%3E%22%29%3B%0A++++++++%3C%2Fscript%3E%0A++++%3C%2Fhead%3E%0A++++%3Cbody%3E%0A++++%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
   46     1        INIT_FCALL                                               'libxml_use_internal_errors'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                                 
   48     4        NEW                                              $7      'DOMDocument'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $7
   49     7        INIT_METHOD_CALL                                         !1, 'loadHTML'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   51    10        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         11        SEND_VAL_EX                                              'script'
         12        DO_FCALL                                      0  $11     
         13        ASSIGN                                                   !2, $11
   54    14        ASSIGN                                                   !3, '%7E%0A%28%3F%28DEFINE%29%0A++++%28%3F%3Csquoted%3E+%27+%5B%5E%27%5Cn%5C%5C%5D%2A%2B+%28%3F%3A+%5C%5C.+%5B%5E%27%5Cn%5C%5C%5D%2A+%29%2A%2B+%27+%29%0A++++%28%3F%3Cdquoted%3E+%22+%5B%5E%22%5Cn%5C%5C%5D%2A%2B+%28%3F%3A+%5C%5C.+%5B%5E%22%5Cn%5C%5C%5D%2A+%29%2A%2B+%22+%29%0A++++%28%3F%3Ctquoted%3E+%60+%5B%5E%60%5C%5C%5D%2A%2B+%28%3Fs%3A+%5C%5C.+%5B%5E%60%5C%5C%5D%2A%29%2A%2B+%60+%29%0A++++%28%3F%3Cquoted%3E++%5Cg%3Csquoted%3E+%7C+%5Cg%3Cdquoted%3E+%7C+%5Cg%3Ctquoted%3E+%29%0A++++%0A++++%28%3F%3Cscomment%3E+%2F%2F+%5CN%2A+%29%0A++++%28%3F%3Cmcomment%3E+%2F%5C%2A+%5B%5E%2A%5D%2A%2B+%28%3F%3A+%5C%2A%2B+%28%3F%21%2F%29+%5B%5E%2A%5D%2A+%29%2A%2B+%5C%2A%2F+%29%0A++++%28%3F%3Ccomment%3E+%5Cg%3Cscomment%3E+%7C+%5Cg%3Cmcomment%3E+%29%0A++++%0A++++%28%3F%3Cpattern%3E+%2F+%28%3F%3D%5B%5E%5Cn%2F%2A%5D%29+%5B%5E%5Cn%2F%5C%5C%5D%2A%2B+%28%3F%3E%5C%5C.%5B%5E%5Cn%2F%5C%5C%5D%2A%29%2A+%2F+%5Bgimuy%5D%2A+%29+%0A%29%0A%0A%28%3F%3D%5B%5B%28%3A%2C%3D%2F%22%27%60%5D%29%0A%28%3F%7C%0A++++%5Cg%3Cquoted%3E+%28%2ASKIP%29%28%2AFAIL%29%0A++%7C%0A++++%28+%5B%5B%28%3A%2C%3D%5D+%5Cs%2A+%29+%28%2ASKIP%29+%28%3F%3A+%5Cg%3Ccomment%3E+%5Cs%2A+%29%2A%2B+%28+%5Cg%3Cpattern%3E+%29%0A++%7C+%0A++++%28+%5Cg%3Cpattern%3E+%5Cs%2A+%29+%28%3F%3A+%5Cg%3Ccomment%3E+%5Cs%2A+%29%2A%2B+%0A++++%28+%5C.+%5Cs%2A+%29+%28%3F%3A%5Cg%3Ccomment%3E+%5Cs%2A+%29%2A%2B+%28%5BA-Za-z_%5D%5Cw%2A%29%0A++%7C%0A++++%5Cg%3Ccomment%3E%0A%29%0A%7Ex'
   83    15      > FE_RESET_R                                       $14     !2, ->26
         16    > > FE_FETCH_R                                               $14, !4, ->26
   84    17    >   INIT_FCALL                                               'preg_replace'
         18        SEND_VAR                                                 !3
         19        SEND_VAL                                                 '%249%24%7B10%7D%24%7B11%7D'
         20        FETCH_OBJ_R                                      ~16     !4, 'nodeValue'
         21        SEND_VAL                                                 ~16
         22        DO_ICALL                                         $17     
         23        ASSIGN_OBJ                                               !4, 'nodeValue'
         24        OP_DATA                                                  $17
   83    25      > JMP                                                      ->16
         26    >   FE_FREE                                                  $14
   87    27        INIT_METHOD_CALL                                         !1, 'saveHTML'
         28        DO_FCALL                                      0  $18     
         29        ASSIGN                                                   !0, $18
   89    30        ECHO                                                     !0
   91    31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.82 ms | 1011 KiB | 15 Q