How to escape HTML tags from a string in PHP?
The PHP function htmlspecialchars() is dedicated to escape or convert special characters in string to HTML entities . the function replaces the following characters:
- ampersand ( & ) => &s;
- double quotation mark ( " ) => "
- single quotation mark ( ' ) => ' ou '
- the sign less than ( < ) => <
- the sign greater than ( > ) => >
For example:
$string = '<a href="https://ans.wiki">Answiki</a>';
$string = htmlspecialchars($string);
// Affiche : <a href="https://ans.wiki">Answiki</a>
echo $string;
See also:
The PHP function htmlspecialchars() is dedicated to escape or convert special characters in string to HTML entities . the function replaces the following characters:
- ampersand ( & ) => &s;
- double quotation mark ( " ) => "
- single quotation mark ( ' ) => ' ou '
- the sign less than ( < ) => <
- the sign greater than ( > ) => >
For example:
$string = '<a href="https://ans.wiki">Answiki</a>';
$string = htmlspecialchars($string);
// Affiche : <a href="https://ans.wiki">Answiki</a>
echo $string;
See also:
The PHP function htmlspecialchars() is dedicated to escape or convert special characters in string to HTML entities . the function replaces the following characters:
- ampersand ( & ) => &s;
- double quotation mark ( " ) => "
- single quotation mark ( ' ) => ' ou '
- the sign less than ( < ) => <
- the sign greater than ( > ) => >
For example:
$string = '<a href="https://ans.wiki">Answiki</a>';
$string = htmlspecialchars($string);
// Affiche : <a href="https://ans.wiki">Answiki</a>
echo $string;
See also:
| # | ID | Query | URL | Count |
|---|---|---|---|---|
| 0 | 13478 | alphons | https://en.ans.wiki/6179/how-to-escape-html-tags-from-a-string-in-php | 1 |
| 1 | 12906 | en | https://en.ans.wiki/6179/how-to-escape-html-tags-from-a-string-in-php | 6 |