3v4l.org

run code in 300+ PHP versions simultaneously
<?php function scrubAttributes($html) { $dom = new DOMDocument(); $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); for ($els = $dom->getElementsByTagname('*'), $i = $els->length - 1; $i >= 0; $i--) { for ($attrs = $els->item($i)->attributes, $ii = $attrs->length - 1; $ii >= 0; $ii--) { $els->item($i)->removeAttribute($attrs->item($ii)->name); } } return $dom->saveHTML(); } $html = '<p style="padding:0px;"> <strong style="padding:0;margin:0;">hello</strong> </p>'; echo scrubAttributes($html);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M2ing
function name:  (null)
number of ops:  6
compiled vars:  !0 = $html
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, '%3Cp+style%3D%22padding%3A0px%3B%22%3E%0A++%3Cstrong+style%3D%22padding%3A0%3Bmargin%3A0%3B%22%3Ehello%3C%2Fstrong%3E%0A%3C%2Fp%3E'
   18     1        INIT_FCALL                                               'scrubattributes'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function scrubattributes:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 16
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 25
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 16
Branch analysis from position: 42
Branch analysis from position: 16
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 25
Branch analysis from position: 39
Branch analysis from position: 25
filename:       /in/M2ing
function name:  scrubAttributes
number of ops:  46
compiled vars:  !0 = $html, !1 = $dom, !2 = $els, !3 = $i, !4 = $attrs, !5 = $ii
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        NEW                                              $6      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
    5     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              8196
          7        DO_FCALL                                      0          
    6     8        INIT_METHOD_CALL                                         !1, 'getElementsByTagname'
          9        SEND_VAL_EX                                              '%2A'
         10        DO_FCALL                                      0  $10     
         11        ASSIGN                                                   !2, $10
         12        FETCH_OBJ_R                                      ~12     !2, 'length'
         13        SUB                                              ~13     ~12, 1
         14        ASSIGN                                                   !3, ~13
         15      > JMP                                                      ->40
    7    16    >   INIT_METHOD_CALL                                         !2, 'item'
         17        SEND_VAR_EX                                              !3
         18        DO_FCALL                                      0  $15     
         19        FETCH_OBJ_R                                      ~16     $15, 'attributes'
         20        ASSIGN                                                   !4, ~16
         21        FETCH_OBJ_R                                      ~18     !4, 'length'
         22        SUB                                              ~19     ~18, 1
         23        ASSIGN                                                   !5, ~19
         24      > JMP                                                      ->37
    8    25    >   INIT_METHOD_CALL                                         !2, 'item'
         26        SEND_VAR_EX                                              !3
         27        DO_FCALL                                      0  $21     
         28        INIT_METHOD_CALL                                         $21, 'removeAttribute'
         29        CHECK_FUNC_ARG                                           
         30        INIT_METHOD_CALL                                         !4, 'item'
         31        SEND_VAR_EX                                              !5
         32        DO_FCALL                                      0  $22     
         33        FETCH_OBJ_FUNC_ARG                               $23     $22, 'name'
         34        SEND_FUNC_ARG                                            $23
         35        DO_FCALL                                      0          
    7    36        PRE_DEC                                                  !5
         37    >   IS_SMALLER_OR_EQUAL                                      0, !5
         38      > JMPNZ                                                    ~26, ->25
    6    39    >   PRE_DEC                                                  !3
         40    >   IS_SMALLER_OR_EQUAL                                      0, !3
         41      > JMPNZ                                                    ~28, ->16
   11    42    >   INIT_METHOD_CALL                                         !1, 'saveHTML'
         43        DO_FCALL                                      0  $29     
         44      > RETURN                                                   $29
   12    45*     > RETURN                                                   null

End of function scrubattributes

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.59 ms | 1003 KiB | 14 Q