3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); $buffer=<<<XML <description><![CDATA[<div id="2" style="all: inherit;"><span style='font-size: 40px'>Testing123</span></div>]]></description> XML; $asString = static function (SimpleXMLElement $el) { return rtrim(explode("\n", $el->asXML(), 2)[1]); }; $makeCdata = static function (SimpleXMLElement $el, string $data) { $el[0] = null; if ($n = dom_import_simplexml($el)) { $cd = $n->ownerDocument->createCDATASection($data); $n->appendChild($cd); } }; $xml = simplexml_load_string($buffer); $cdata = simplexml_load_string((string)$xml); foreach ($cdata->xpath('@*[name(.) != "id"]|*/@*') as $attribute) unset($attribute[0]) ; $makeCdata($xml, $asString($cdata)); echo $xml->asXML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/SUnNV
function name:  (null)
number of ops:  33
compiled vars:  !0 = $buffer, !1 = $asString, !2 = $makeCdata, !3 = $xml, !4 = $cdata, !5 = $attribute
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdescription%3E%3C%21%5BCDATA%5B%3Cdiv+id%3D%222%22+style%3D%22all%3A+inherit%3B%22%3E%3Cspan+style%3D%27font-size%3A+40px%27%3ETesting123%3C%2Fspan%3E%3C%2Fdiv%3E%5D%5D%3E%3C%2Fdescription%3E'
    7     1        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
          2        ASSIGN                                                   !1, ~7
   10     3        DECLARE_LAMBDA_FUNCTION                          ~9      [1]
          4        ASSIGN                                                   !2, ~9
   18     5        INIT_FCALL                                               'simplexml_load_string'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $11     
          8        ASSIGN                                                   !3, $11
   19     9        INIT_FCALL                                               'simplexml_load_string'
         10        CAST                                          6  ~13     !3
         11        SEND_VAL                                                 ~13
         12        DO_ICALL                                         $14     
         13        ASSIGN                                                   !4, $14
   20    14        INIT_METHOD_CALL                                         !4, 'xpath'
         15        SEND_VAL_EX                                              '%40%2A%5Bname%28.%29+%21%3D+%22id%22%5D%7C%2A%2F%40%2A'
         16        DO_FCALL                                      0  $16     
         17      > FE_RESET_R                                       $17     $16, ->21
         18    > > FE_FETCH_R                                               $17, !5, ->21
   21    19    >   UNSET_DIM                                                !5, 0
   20    20      > JMP                                                      ->18
         21    >   FE_FREE                                                  $17
   23    22        INIT_DYNAMIC_CALL                                        !2
         23        SEND_VAR_EX                                              !3
         24        INIT_DYNAMIC_CALL                                        !1
         25        SEND_VAR_EX                                              !4
         26        DO_FCALL                                      0  $18     
         27        SEND_VAR_NO_REF_EX                                       $18
         28        DO_FCALL                                      0          
   24    29        INIT_METHOD_CALL                                         !3, 'asXML'
         30        DO_FCALL                                      0  $20     
         31        ECHO                                                     $20
         32      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SUnNV
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $el
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        INIT_FCALL                                               'rtrim'
          2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%0A'
          4        INIT_METHOD_CALL                                         !0, 'asXML'
          5        DO_FCALL                                      0  $1      
          6        SEND_VAR                                                 $1
          7        SEND_VAL                                                 2
          8        DO_ICALL                                         $2      
          9        FETCH_DIM_R                                      ~3      $2, 1
         10        SEND_VAL                                                 ~3
         11        DO_ICALL                                         $4      
         12      > RETURN                                                   $4
    9    13*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/SUnNV
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $el, !1 = $data, !2 = $n, !3 = $cd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        ASSIGN_DIM                                               !0, 0
          3        OP_DATA                                                  null
   12     4        INIT_FCALL                                               'dom_import_simplexml'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $5      
          7        ASSIGN                                           ~6      !2, $5
          8      > JMPZ                                                     ~6, ->17
   13     9    >   FETCH_OBJ_R                                      ~7      !2, 'ownerDocument'
         10        INIT_METHOD_CALL                                         ~7, 'createCDATASection'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0  $8      
         13        ASSIGN                                                   !3, $8
   14    14        INIT_METHOD_CALL                                         !2, 'appendChild'
         15        SEND_VAR_EX                                              !3
         16        DO_FCALL                                      0          
   16    17    > > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.82 ms | 1008 KiB | 17 Q