3v4l.org

run code in 300+ 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:  25
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        INIT_FCALL                                               'preg_replace'
          9        SEND_VAL                                                 '%7E%26%28%3F%21%5Cw%2B%3B%29%7E'
         10        SEND_VAL                                                 '%26amp%3B'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $7      
         13        ASSIGN                                                   !1, $7
   12    14        CONCAT                                           ~9      !1, '%0A'
         15        ECHO                                                     ~9
   14    16        INIT_FCALL                                               'str_replace'
         17        SEND_VAL                                                 '%26amp%3B'
         18        SEND_VAL                                                 '%26'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $10     
         21        ASSIGN                                                   !1, $10
   15    22        CONCAT                                           ~12     !1, '%0A'
         23        ECHO                                                     ~12
         24      > 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:  8
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 '%26amp%3B'
          3        SEND_VAL                                                 '%26amp%3Bamp%3B'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6      > RETURN                                                   $1
    5     7*     > RETURN                                                   null

End of function preserveampersandescapeinoptiontagforfomanticuidropdownwithpreservehtmlfalse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.19 ms | 1014 KiB | 16 Q