3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<'XML' <nitf:body.content xmlns:nitf="foo"> <nitf:block> <nitf:p style="@style1">Contents of paragraph1.</nitf:p> <nitf:p style="@style2">Contents of paragraph2.</nitf:p> <nitf:p style="@style1"><nitf:em class="@bold">This is bold</nitf:em> This is not bold</nitf:p> <nitf:p style="@style1"><nitf:em class="@italic">This is italic</nitf:em> This is not italic</nitf:p> </nitf:block> </nitf:body.content> XML; $nitfNS = "foo"; $doc = new DOMDocument(); $doc->loadXML($xml); foreach($doc->getElementsByTagNameNS($nitfNS, 'em') as $em) { $class = $em->getAttribute('class'); if ($class == '@italic') { $em->nodeValue = '<i>' . $em->nodeValue . '</i>'; } elseif (strpos($class, 'bold') !== FALSE) { $em->nodeValue = '<b>' . $em->nodeValue . '</b>'; } echo $doc->saveXML($em), "\n"; } foreach ($doc->getElementsByTagNameNS($nitfNS, 'p') as $element) { $textnode = $element->childNodes->item(0); echo $textnode->textContent, "\n"; } echo $doc->saveXML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 43
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 43
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 37
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 37
Branch analysis from position: 43
2 jumps found. (Code = 77) Position 1 = 49, Position 2 = 59
Branch analysis from position: 49
2 jumps found. (Code = 78) Position 1 = 50, Position 2 = 59
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
Branch analysis from position: 43
filename:       /in/8de8a
function name:  (null)
number of ops:  64
compiled vars:  !0 = $xml, !1 = $nitfNS, !2 = $doc, !3 = $em, !4 = $class, !5 = $element, !6 = $textnode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, '%3Cnitf%3Abody.content+xmlns%3Anitf%3D%22foo%22%3E%0A++%3Cnitf%3Ablock%3E%0A++++%3Cnitf%3Ap+style%3D%22%40style1%22%3EContents+of+paragraph1.%3C%2Fnitf%3Ap%3E%0A++++%3Cnitf%3Ap+style%3D%22%40style2%22%3EContents+of+paragraph2.%3C%2Fnitf%3Ap%3E%0A++++%3Cnitf%3Ap+style%3D%22%40style1%22%3E%3Cnitf%3Aem+class%3D%22%40bold%22%3EThis+is+bold%3C%2Fnitf%3Aem%3E+This+is+not+bold%3C%2Fnitf%3Ap%3E%0A++++%3Cnitf%3Ap+style%3D%22%40style1%22%3E%3Cnitf%3Aem+class%3D%22%40italic%22%3EThis+is+italic%3C%2Fnitf%3Aem%3E+This+is+not+italic%3C%2Fnitf%3Ap%3E%0A++%3C%2Fnitf%3Ablock%3E%0A%3C%2Fnitf%3Abody.content%3E'
   15     1        ASSIGN                                                   !1, 'foo'
   17     2        NEW                                              $9      'DOMDocument'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $9
   18     5        INIT_METHOD_CALL                                         !2, 'loadXML'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
   20     8        INIT_METHOD_CALL                                         !2, 'getElementsByTagNameNS'
          9        SEND_VAR_EX                                              !1
         10        SEND_VAL_EX                                              'em'
         11        DO_FCALL                                      0  $13     
         12      > FE_RESET_R                                       $14     $13, ->43
         13    > > FE_FETCH_R                                               $14, !3, ->43
   21    14    >   INIT_METHOD_CALL                                         !3, 'getAttribute'
         15        SEND_VAL_EX                                              'class'
         16        DO_FCALL                                      0  $15     
         17        ASSIGN                                                   !4, $15
   22    18        IS_EQUAL                                                 !4, '%40italic'
         19      > JMPZ                                                     ~17, ->26
   23    20    >   FETCH_OBJ_R                                      ~19     !3, 'nodeValue'
         21        CONCAT                                           ~20     '%3Ci%3E', ~19
         22        CONCAT                                           ~21     ~20, '%3C%2Fi%3E'
         23        ASSIGN_OBJ                                               !3, 'nodeValue'
         24        OP_DATA                                                  ~21
         25      > JMP                                                      ->37
   25    26    >   INIT_FCALL                                               'strpos'
         27        SEND_VAR                                                 !4
         28        SEND_VAL                                                 'bold'
         29        DO_ICALL                                         $22     
         30        TYPE_CHECK                                  1018          $22
         31      > JMPZ                                                     ~23, ->37
   26    32    >   FETCH_OBJ_R                                      ~25     !3, 'nodeValue'
         33        CONCAT                                           ~26     '%3Cb%3E', ~25
         34        CONCAT                                           ~27     ~26, '%3C%2Fb%3E'
         35        ASSIGN_OBJ                                               !3, 'nodeValue'
         36        OP_DATA                                                  ~27
   28    37    >   INIT_METHOD_CALL                                         !2, 'saveXML'
         38        SEND_VAR_EX                                              !3
         39        DO_FCALL                                      0  $28     
         40        ECHO                                                     $28
         41        ECHO                                                     '%0A'
   20    42      > JMP                                                      ->13
         43    >   FE_FREE                                                  $14
   31    44        INIT_METHOD_CALL                                         !2, 'getElementsByTagNameNS'
         45        SEND_VAR_EX                                              !1
         46        SEND_VAL_EX                                              'p'
         47        DO_FCALL                                      0  $29     
         48      > FE_RESET_R                                       $30     $29, ->59
         49    > > FE_FETCH_R                                               $30, !5, ->59
   32    50    >   FETCH_OBJ_R                                      ~31     !5, 'childNodes'
         51        INIT_METHOD_CALL                                         ~31, 'item'
         52        SEND_VAL_EX                                              0
         53        DO_FCALL                                      0  $32     
         54        ASSIGN                                                   !6, $32
   33    55        FETCH_OBJ_R                                      ~34     !6, 'textContent'
         56        ECHO                                                     ~34
         57        ECHO                                                     '%0A'
   31    58      > JMP                                                      ->49
         59    >   FE_FREE                                                  $30
   36    60        INIT_METHOD_CALL                                         !2, 'saveXML'
         61        DO_FCALL                                      0  $35     
         62        ECHO                                                     $35
         63      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.71 ms | 1400 KiB | 15 Q