PHP programming fastest understanding Lecture 8: php inspiration and summary. At the same time, many functions can be implemented in multiple ways, which requires flexible use. Only by remembering these functions can a dynamic website be developed. There are also multiple methods to implement the functions of the entire website. This requires flexible use. Only by remembering these functions can we develop dynamic websites. only by having to develop more exercises and the whole website once can we skillfully perform the next development and discover and improve our own shortcomings.
Many methods can be improved, such as the counter:
Instance 24 counters
The code is as follows:
// Counter
Function countx ($ file = "count. dat "){
If (file_exists ($ file )){
$ Fp = fopen ($ file, "r ");
$ Numx = fgets ($ fp, 10 );
Fclose ($ fp );
$ Numx ++;
// The above four lines of code can be replaced by an expression: $ numx = file_get_contents ($ file) + 1;
}
Else {
$ Numx = 1 ;}
File_put_contents ($ file, $ numx); // when the file does not exist, this function automatically creates the file and converts the parameter to a string for writing.
Echo $ numx;
/* The entire function body can be replaced by two expressions: file_exists ($ file )? File_put_contents ($ file, file_get_contents ($ file) + 1): file_put_contents ($ file, "1"); readfile ($ file );
*/
}
// Function call
Countx ();
?>
There are many implementation methods, so let's think twice.
In the final example, the time used to run the computing code during debugging is measured in seconds and output in five decimal places, which is equivalent to the search time of the search engine and is often used for optimization such as SQL, the code is as follows:
Instance 25 calculates the code running time and optimizes the code
The code is as follows:
$ Ftime = microtime ();
Countx (); // The code used to calculate the running time. This is the function in the previous example.
$ Ftime = number_format (microtime ()-$ ftime), 5 );
Echo $ ftime;
?>
This tutorial is based on examples. it is rarely described. these codes are not difficult and functions are also well-selected. my goal is to quickly use them, for example, to process Chinese characters, what can I do if I copy what I say in a book that can only process functions in English? Or if I take out a function that you cannot use, it will be a waste of time.
I didn't talk about simple syntax, but I believe that the syntax and basics are not a problem through representative examples. In addition, this tutorial is intended for beginners and intermediate people. it is enough to develop practical websites. In the future, I will give more advanced tutorials, such as sock, XML, ZIP, PDF, Mail and other class library development, and compile my own CMS. I try to understand it as quickly as possible. if not, I need to understand it faster!
Thank you again. this is the preliminary and intermediate tutorial. you are busy now. you can visit www.kuphp.com to learn from each other!
If you see more tired, here are packaged pdf and doc version http://www.jb51.net/books/32601.html
Bytes. Only by remembering these functions can a dynamic website be developed; and only by having to practice more, the entire website is launched...