Many people think that htmlentities and htmlspecialchars function is the same, are formatted HTML code, I used to think so, but today I found that is not the case.The translations performed is:Copy CodeThe code is as follows:' & ' (ampersand)
The translations performed is:
Copy CodeThe code is as follows:
' & ' (ampersand) becomes ' & '
' ' ' (double quote) becomes ' "When Ent_noquotes was not set.
"(single quote) becomes" only if Ent_quotes is set.
' ' > ' (greater than) becomes ' > '
The translations saved med are:
CopyCode The Code is as follows: '&' (ampersand) becomes '&'
'"' (Double quote) becomes '" 'when ent_noquotes is not set.
''' (Single quote) becomes ''' only when ent_quotes is set.
''>' (Greater than) becomes '>'
Htmlspecialchars and htmlentities usage in php. In php, htmlspecialchars converts special characters into HTML format, while htmlentities converts all the elements into HTML strings. next I will briefly introduce them. Htmlentities usage
The htmlentities function in PHP is so understandable to the htmlentities function. because the browser does not know the htmlentities function by directly inputting some characters, garbled characters may appear, so we need to use this function to
In php, htmlspecialchars converts special characters into HTML format, while htmlentities converts all the elements into HTML strings. Next I will briefly introduce them.
Htmlentities usage
$ Str = "John & 'adams '";
Echo htmlentities ($ str,
Use htmlentities and htmlspecialchars to filter input operations in php, and use htmlspecialchars to filter input operations
This example describes how to filter input in php using htmlentities and htmlspecialchars. We will share this with you for
The PHP htmlentities () function converts characters to HTML entities, this article introduces the PHP htmlentities () function Basic use method and the example introduction, needs the code agriculture may refer to.
Definitions and usage
The
There are two functions in php: htmlentities and htmlspecialchars. both functions are explained in English in the php Manual. the description of the htmlentities function contains the following two functions in php: htmlentities and htmlspecialchars,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.