3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sample = new SimpleXMLElement('<root><parent><child1></child1></parent></root>'); $node = $sample->xpath('//parent'); $node[0]->addChild('child2'); echo f($sample); function f(SimpleXMLElement $x) { $doc = dom_import_simplexml($x)->ownerDocument; $doc->formatOutput = true; return $doc->saveXML(); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VR04Q
function name:  (null)
number of ops:  17
compiled vars:  !0 = $sample, !1 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $2      'SimpleXMLElement'
          1        SEND_VAL_EX                                              '%3Croot%3E%3Cparent%3E%3Cchild1%3E%3C%2Fchild1%3E%3C%2Fparent%3E%3C%2Froot%3E'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
    5     4        INIT_METHOD_CALL                                         !0, 'xpath'
          5        SEND_VAL_EX                                              '%2F%2Fparent'
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !1, $5
    6     8        FETCH_DIM_R                                      ~7      !1, 0
          9        INIT_METHOD_CALL                                         ~7, 'addChild'
         10        SEND_VAL_EX                                              'child2'
         11        DO_FCALL                                      0          
    7    12        INIT_FCALL_BY_NAME                                       'f'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0  $9      
         15        ECHO                                                     $9
   13    16      > RETURN                                                   1

Function f:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VR04Q
function name:  f
number of ops:  12
compiled vars:  !0 = $x, !1 = $doc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'dom_import_simplexml'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        FETCH_OBJ_R                                      ~3      $2, 'ownerDocument'
          5        ASSIGN                                                   !1, ~3
   11     6        ASSIGN_OBJ                                               !1, 'formatOutput'
          7        OP_DATA                                                  <true>
   12     8        INIT_METHOD_CALL                                         !1, 'saveXML'
          9        DO_FCALL                                      0  $6      
         10      > RETURN                                                   $6
   13    11*     > RETURN                                                   null

End of function f

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.29 ms | 1388 KiB | 15 Q