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 |
---|