encode entities
This function encodes the following special characters into character entities:
Characters | Character Entity Conversion |
---|---|
> | > (greater than) |
< | < (less than) |
" | " (double quotation marks) |
' | ' (apostrophe / single quotation marks) |
& | & (ampersand symbol) |
All control characters | nnn; (e.g. new line, tab, backspace, escape) |
ANSI 0 (NUL) | Will be ignored |
All non-ANSI characters | nnn; (e.g. &eur; ≥ é) |
Consecutive spaces |   (every 2nd space is converted) |
See dump entities() to obtain a complete list of entities B4P is supporting.
Indirect parameter passing is disabled
1-2
No. | Type | Description |
---|---|---|
1 input |
string | input string Original string containing special characters |
Opt. 2 input |
boolean | use new line in html format If false: Converts to
|
Type | Description |
---|---|
string | String with encoded characters Converted string with encoded characters |
Invalid character code (outside 0 - 1114111 range)
echo( encode entities( '4.50 € <TABLE> "..." </DIV>' ) );
echo( encode entities( Line 1 + new line + Line 2, false ) ); // use
echo( encode entities( Line 1 + new line + Line 2, true ) ); // use <BR/>
4.50 €  <TABLE> "..." </DIV>
Line 1 Line 2
Line 1<BR/>Line 2