3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SimpleXMLExtended extends SimpleXMLElement { public function addCData($cdata_text) { $node = dom_import_simplexml($this); $no = $node->ownerDocument; $node->appendChild($no->createCDATASection($cdata_text)); } } $oXML = new SimpleXMLExtended('<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0" />'); $oChannel = $oXML->addChild('channel'); $oChannel->addChild('title', 'TEST'); $oProduct = $oChannel->addChild('item'); $oProduct->addChild('product_type', 'used', 'http://base.google.com/ns/1.0'); echo $oXML->asXML();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/glHhU
function name:  (null)
number of ops:  25
compiled vars:  !0 = $oXML, !1 = $oChannel, !2 = $oProduct
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $3      'SimpleXMLExtended'
          1        SEND_VAL_EX                                              '%3Crss+xmlns%3Ag%3D%22http%3A%2F%2Fbase.google.com%2Fns%2F1.0%22+version%3D%222.0%22+%2F%3E'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   11     4        INIT_METHOD_CALL                                         !0, 'addChild'
          5        SEND_VAL_EX                                              'channel'
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !1, $6
   12     8        INIT_METHOD_CALL                                         !1, 'addChild'
          9        SEND_VAL_EX                                              'title'
         10        SEND_VAL_EX                                              'TEST'
         11        DO_FCALL                                      0          
   14    12        INIT_METHOD_CALL                                         !1, 'addChild'
         13        SEND_VAL_EX                                              'item'
         14        DO_FCALL                                      0  $9      
         15        ASSIGN                                                   !2, $9
   15    16        INIT_METHOD_CALL                                         !2, 'addChild'
         17        SEND_VAL_EX                                              'product_type'
         18        SEND_VAL_EX                                              'used'
         19        SEND_VAL_EX                                              'http%3A%2F%2Fbase.google.com%2Fns%2F1.0'
         20        DO_FCALL                                      0          
   18    21        INIT_METHOD_CALL                                         !0, 'asXML'
         22        DO_FCALL                                      0  $12     
         23        ECHO                                                     $12
         24      > RETURN                                                   1

Class SimpleXMLExtended:
Function addcdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/glHhU
function name:  addCData
number of ops:  15
compiled vars:  !0 = $cdata_text, !1 = $node, !2 = $no
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'dom_import_simplexml'
          2        FETCH_THIS                                       ~3      
          3        SEND_VAL                                                 ~3
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
    5     6        FETCH_OBJ_R                                      ~6      !1, 'ownerDocument'
          7        ASSIGN                                                   !2, ~6
    6     8        INIT_METHOD_CALL                                         !1, 'appendChild'
          9        INIT_METHOD_CALL                                         !2, 'createCDATASection'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0  $8      
         12        SEND_VAR_NO_REF_EX                                       $8
         13        DO_FCALL                                      0          
    7    14      > RETURN                                                   null

End of function addcdata

End of class SimpleXMLExtended.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.11 ms | 1005 KiB | 14 Q