3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /** * PHP DOM and JavaScript with HTML entities * @link http://stackoverflow.com/q/18487515/367456 */ $doc = new DOMDocument(); $doc->loadHTML('<head/>'); $script = $doc->createElement('script', "\n if (1 < 4) {\n alert(\"hello\");\n }\n"); $head = $doc->getElementsByTagName('head')->item(0); $scriptInHead = $head->appendChild($script); echo $doc->saveHTML();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MFf1Z
function name:  (null)
number of ops:  26
compiled vars:  !0 = $doc, !1 = $script, !2 = $head, !3 = $scriptInHead
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   7     0  E >   NEW                                              $4      :-5
         1        DO_FCALL                                      0          
         2        ASSIGN                                                   !0, $4
   8     3        INIT_METHOD_CALL                                         !0, 'loadHTML'
         4        SEND_VAL_EX                                              '%3Chead%2F%3E'
         5        DO_FCALL                                      0          
  10     6        INIT_METHOD_CALL                                         !0, 'createElement'
         7        SEND_VAL_EX                                              'script'
         8        SEND_VAL_EX                                              '%0A++if+%281+%3C+4%29+%7B%0A++++alert%28%22hello%22%29%3B%0A++%7D%0A'
         9        DO_FCALL                                      0  $8      
        10        ASSIGN                                                   !1, $8
  12    11        INIT_METHOD_CALL                                         !0, 'getElementsByTagName'
        12        SEND_VAL_EX                                              'head'
        13        DO_FCALL                                      0  $10     
        14        INIT_METHOD_CALL                                         $10, 'item'
        15        SEND_VAL_EX                                              0
        16        DO_FCALL                                      0  $11     
        17        ASSIGN                                                   !2, $11
  13    18        INIT_METHOD_CALL                                         !2, 'appendChild'
        19        SEND_VAR_EX                                              !1
        20        DO_FCALL                                      0  $13     
        21        ASSIGN                                                   !3, $13
  15    22        INIT_METHOD_CALL                                         !0, 'saveHTML'
        23        DO_FCALL                                      0  $15     
        24        ECHO                                                     $15
        25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 7.3.0