So love micro-network now explains php built-in functions
Case-sensitive conversion functions
Text html Tag processing function
Case-sensitive functionsCopy codeThe Code is as follows: strtolower ()
Strtoupper ()
Ucfirst ()
Ucword ()
String formatting functions related to HTML tagsCopy codeThe Code is as follows: nl2br ()
Htmllentities ()
Htmlspecialchars ()
Stripslashes ()
Strip_tags ()
Number_format ()
Strrev ()
Md5 ()
In php, all string processing functions are not modified on the original string, but return a newly formatted string.Copy codeThe Code is as follows: <? Php
// Convert to lowercase
$ A = 'www .jb51.net ';
Echo strtolower ($ );
// Result: www.jb51.net
// Convert to uppercase
$ A = 'www .jb51.net ';
Echo strtoupper ($ );
// Result: WWW.jb51.net
// Uppercase letters
$ A = 'www .jb51.net ';
Echo ucfirst ($ );
// Result: Www.jb51.net
// Uppercase letters of each word
$ A = 'I love you ';
Echo ucword ($ );
// Result: I Love You
/*
Tip: we all know the case sensitivity. Do you think the case sensitivity is different from the case sensitivity and the Case sensitivity?
In Windows, php is not case sensitive, but cannot be case insensitive in linux.
For example
When the class is automatically loaded
<? Php
Function _ autoload ($ className ){
Include strtolower ($ className). '. class. php ';
}
$ Obj = new MyClass;
In this way, myclass. class. php will be loaded.
Because the file name is often lowercase, it must be converted to lowercase.
?>
*/
// Nl2br converts spaces into entities <br/> because the line breaks are generally displayed in the browser. <br/> for example, the line breaks must be converted in the form message book. Otherwise, the lines cannot be converted. all tasks contain spaces.
$ A ='
I
Love
You
';
Echo $;
Echo nl2br ($ );
Result 1: I love you.
Result 2:
I
Love
You
// If you do not perform html Tag processing for form submission, the style or js Code will be displayed and run directly.
/*
<Form>
<Input type = 'text' name = 'title'>
<Input type = 'submit 'name = 'submit 'value = 'Submit'>
</Form>
When you enter
<H1> www.jb51.net <H1>
A large font is displayed upon submission.
But you wanted
<H1> www.jb51.net <H1> result
So proceed
When you enter <script> alert ('www .jb51.net') </script>
Javascript will be run once submitted
If this is not the case, you have to deal with it to prevent hackers from finding the entrance to your attack.
The default form submission method is get.
*/
// When you enter <div> Echo htmlspecialchars ($ _ GET ['title']); // filtered
Result: <div> When you view the source code, you will know that <and> has been replaced with & lt & gt, and the prototype is displayed on the page.
Another important thing is that, if you do not deal with <div> some of the articles that have been copied have their own tag styles, your page layout may be disrupted and css conflicts may occur.
Htmllentities () function user and htmlspecialchars () are not used in the opposite way.
The strip_tags () function can be used when you need to keep the tag.
Echo strip_tags ($ _ GET ['title'], '<B> <p> <strong> If you view the source code, you will find that <div> no more
/*
Add the input I love 'jb51 ';
The submission result is I love \ 'jb51 \ '. The backslash is escaped.
What should I do if I want to output the original text?
You can use this php function stripslashes ()
Cancel escape
Echo stripslashes ($ _ GET ['title']);
The result is I love 'jb51 ';
What if html tags are contained?
<A href = "http://www.jb51.net/"> I love 'jb51 '</a>
What should I do with prototype output? I can combine two functions to use what I have already said.
Echo htmlspecialchars (stripslashes ($ _ GET ['title']);
Results: <a href = "http://www.jb51.net/"> I love 'jb51' </a>
*/
// Number_format () This function is used to format the currency function. Different countries have different habits, so the display of the required currency is different. For example, the Chinese money in the mall is usually in this format.
Use commas (,) to retain the number of decimal places'
This function is easy to use.
Number_format ($ money, which indicates the number of decimal points reserved. 'What are the decimal points separated 'And 'What are the decimal points separated ')
$ Price = '1970. 100 ';
Echo number_format ($ money, 2 ,',','.');
Result: 123.465.789, 23
Echo number_format ($ money, 2, '.', ','); // Chinese
Result: 123,465,789.23
// Strrev () returns the string
$ Str = 'HTTP: // www.jb51.net ';
Echo strrev ($ str );
Result: moc. tenwii. www //: ptth
// Md5 indicates that the user name and password must be encrypted to prevent hackers.
$ A = 'admin ';
Echo $ B = md5 ($ );