So love Micro net now explain PHP built-in functions
Uppercase and lowercase conversion related functions
Text HTML tag handler function
Case-sensitive about functions
Copy CodeThe code is as follows:
Strtolower ()
Strtoupper ()
Ucfirst ()
Ucword ()
HTML tag-related string formatting functions
Copy CodeThe code is as follows:
NL2BR ()
Htmllentities ()
Htmlspecialchars ()
Stripslashes ()
Strip_tags ()
Number_format ()
Strrev ()
MD5 ()
All string handlers in PHP are not modified on the original string, but instead return a new formatted string
Copy CodeThe code is as follows:
Convert to lowercase
$a = ' www.jb51.net ';
echo strtolower ($a);
Results: Www.jb51.net
Convert to uppercase
$a = ' www.jb51.net ';
echo strtoupper ($a);
Results: WWW.jb51.net
Capitalize first letter
$a = ' www.jb51.net ';
echo Ucfirst ($a);
Results: Www.jb51.net
Capitalize the first letter of each word
$a = ' I love you ';
echo Ucword ($a);
Results: I Love You
/*
Tip: We all know the case, think lowercase and uppercase is different, but why to distinguish between case?
In the win system, PHP size is not strict, but under the Linux system is strictly prohibited to pull large lowercase can not write
Like what
When the class is loaded automatically
function _autoload ($className) {
Include Strtolower ($className). Class.php ';
}
$obj = new MyClass;
This will load the myclass.class.php
Because the file name is usually lowercase, you must convert lowercase
?>
*/
NL2BR to convert a space into an entity
Because the line breaks that are normally displayed in the browser are
For example, in the form of the message book must be converted or the broken line is not successful more space is the task is a space
$a = '
I
Love
You
';
echo $a;
echo nl2br ($a);
Result 1:i Love You
Result 2:
I
Love
You
Form submission If you do not do HTML tag processing then it will directly display the style or JS code directly run
/*
When you enter
Www.jb51.net
A submission appears to be a large font size
But you were trying to
Www.jb51.net
Results of
So to deal with the next
When the input
A commit will run JavaScript
It must be handled to prevent hackers from finding the entrance to your attack.
Form default Submission method is get
*/
When you enter
Www.jb51.net
echo htmlspecialchars ($_get[' title ');//Filter
Results:
Www.jb51.net
Other view source know < and > has been replaced by < &GT will be displayed in the page prototype
There is a point to the main if you do not handle the copy of the article itself has a label style will disrupt your page layout possible CSS conflicts
Htmllentities () function user and htmlspecialchars () the opposite is not said.
When you need that label, you can use the Strip_tags () function.
echo strip_tags ($_get[' title '), '
');
Submit the result is that you look at the source code will find out
/*
Add input I love ' jb51 ';
The result of the submission is I love \ ' jb51\ ' backslash escaped
So what do I have to do with the original output?
You can use this PHP function stripslashes ()
Cancel Escape
echo stripslashes ($_get[' title ');
The result is I love ' jb51 ';
If you have HTML tags like this
I love ' jb51 '
I want the prototype output, how can I use 2 functions to combine with what I've already said
Echo Htmlspecialchars (stripslashes ($_get[' title '));
Result: I love ' jb51 '
*/
Number_format () This function is formatted currency function different countries ' habits are not the same so the need for the currency display is not the same as the mall China money is usually the format of such
Thousands of bits are separated with commas to keep a few dots person ' decimal '
The use of this function is simple
Number_format ($money, the decimal point to keep a few, ' what separates the decimal point ', ' what separates the Thousand Points ')
$price = ' 123465789.233 ';
Echo Number_format ($money, 2, ', ', '. ');
Results: 123.465.789,23
Echo Number_format ($money, 2, '. ', ', ');//Chinese-style
Results: 123,465,789.23
Strrev () the string instead
$str = ' http://www.jb51.net ';
echo Strrev ($STR);
Results: moc.tenwii.www//:p TTH
MD5 is encrypted user name password must be encrypted to prevent hackers
$a = ' admin ';
echo $b = MD5 ($a);
http://www.bkjia.com/PHPjc/325714.html www.bkjia.com true http://www.bkjia.com/PHPjc/325714.html techarticle so love Micro Web now explain the first PHP built-in function has case-sensitive conversion correlation function text HTML tag handler function case about function copy code code as follows: Strtolower () strtoupper () ...