"PHP programming fastest Clear" eighth: PHP Inspiration and summary _php tutorial

Source: Internet
Author: User
At the same time, there are many functions that can be implemented in many ways, which need to be used flexibly. Only remember these functions, in order to develop a dynamic site, but also more practice, the entire site development once, to be skilled in the next development, only to find their shortcomings and improve.

Many methods can be improved, such as this counter:

Instance 24 counter
Copy CodeThe 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 automatically turns the parameter into a string write.
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 ();
?>

The way to do it is, let's think about it a bit more.

The last example, is the debugging of the use of the calculation code to run the time, in seconds to five decimal places output, equivalent to search engine searching time, commonly used in SQL and other optimizations, the code is as follows:

Example 25 calculating the elapsed time for code to run, optimizing the code
Copy CodeThe code is as follows:
$ftime =microtime ();
Countx ();//Place the code to calculate the elapsed time of the run, which is the function that calls the previous example.
$ftime =number_format ((Microtime ()-$ftime), 5);
Echo $ftime;
?>

I this tutorial basic examples, rarely tell, these code is not difficult, the function is also carefully selected, my purpose is to be able to quickly use up, such as can handle Chinese, if I copy the book said can only handle the function of English, what is the use? Or if I take out the function you can't use, it's a waste of time.

I do not speak simple grammar, but I believe that the practice of a representative example, grammar and foundation are not a problem. There is this tutorial is I for the beginning, intermediate people, the development of practical web site enough. I will be a bit more advanced tutorials, such as sock, XML, ZIP, PDF, mail and other class library development, as well as write their own CMS and so on. I strive to understand the fastest, not to be faster to understand it!

Thank you again, this junior high-level tutorial on this to here, and now relatively busy, we can also visit my website www.kuphp.com, learn from each other!

If you look tired, there is a packed PDF and doc version of the download address http://www.jb51.net/books/32601.html

http://www.bkjia.com/PHPjc/322668.html www.bkjia.com true http://www.bkjia.com/PHPjc/322668.html techarticle at the same time, there are many functions that can be implemented in many ways, which need to be used flexibly. Only by remembering these functions can we develop a dynamic website, and only practise more, the whole website opens ...

  • Related Article

    Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.