3v4l.org

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

End of function scrubattributes

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.65 ms | 1016 KiB | 14 Q