3v4l.org

run code in 500+ PHP versions simultaneously
<?php function preserveAmpersandEscapeInOptionTagForFomanticUiDropdownWithPreserveHtmlFalse($v) { return str_replace('&amp;', '&amp;amp;', $v); } $in = 'A & B &amp;'; // example of text to preserve $in .= ' ' . preserveAmpersandEscapeInOptionTagForFomanticUiDropdownWithPreserveHtmlFalse($in); // example of escaping the text to preserve it 1:1 echo $in . "\n"; $str = preg_replace('~&(?!\w+;)~', '&amp;', $in); // done by browser when parsing/normalizing HTML echo $str . "\n"; $str = str_replace('&amp;', '&', $in); // done by https://github.com/fomantic/Fomantic-UI/pull/3224/commits/0bc8f67dcb echo $str . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/E2BQY
function name:  (null)
number of ops:  19
compiled vars:  !0 = $in, !1 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                       !0, 'A+%26+B+%26amp%3B'
    8     1        INIT_FCALL                                                   'preserveampersandescapeinoptiontagforfomanticuidropdownwithpreservehtmlfalse'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $3      
          4        CONCAT                                               ~4      '++++', $3
          5        ASSIGN_OP                                         8          !0, ~4
    9     6        CONCAT                                               ~6      !0, '%0A'
          7        ECHO                                                         ~6
   11     8        FRAMELESS_ICALL_3                preg_replace        ~7      '%7E%26%28%3F%21%5Cw%2B%3B%29%7E', '%26amp%3B'
          9        OP_DATA                                                      !0
         10        ASSIGN                                                       !1, ~7
   12    11        CONCAT                                               ~9      !1, '%0A'
         12        ECHO                                                         ~9
   14    13        FRAMELESS_ICALL_3                str_replace         ~10     '%26amp%3B', '%26'
         14        OP_DATA                                                      !0
         15        ASSIGN                                                       !1, ~10
   15    16        CONCAT                                               ~12     !1, '%0A'
         17        ECHO                                                         ~12
         18      > RETURN                                                       1

Function preserveampersandescapeinoptiontagforfomanticuidropdownwithpreservehtmlfalse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/E2BQY
function name:  preserveAmpersandEscapeInOptionTagForFomanticUiDropdownWithPreserveHtmlFalse
number of ops:  5
compiled vars:  !0 = $v
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        FRAMELESS_ICALL_3                str_replace         ~1      '%26amp%3B', '%26amp%3Bamp%3B'
          2        OP_DATA                                                      !0
          3      > RETURN                                                       ~1
    5     4*     > RETURN                                                       null

End of function preserveampersandescapeinoptiontagforfomanticuidropdownwithpreservehtmlfalse

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
184.18 ms | 1522 KiB | 14 Q