Write beautiful code-separate the daemon from the front-end Program _php Tutorial

Source: Internet
Author: User
When writing a PHP program, some code is used to handle some transactions, such as manipulating databases, doing mathematical operations, and some other code is just the result of transaction processing, For example, some of the PHP code that uses the Echo statement to display the results in HTML format on a Web browser and those that embed directly into a PHP program. First of all, we should clearly distinguish between these two code, the former is called the background program, the latter is called the front-end program.


Because PHP is an embedded programming language, that is, all of the PHP code can be embedded in the HTML code, which brings a lot of convenience to the program writing. However, "extremes meet", if the PHP code and HTML code mixed in a longer program, this will make the program disorganized, not conducive to the maintenance and reading of the program. So we need to try to transplant the PHP code in these programs into the HTML code as much as possible, encapsulate the code into functions in a specialized file, and then use the INCLUDE statement in the HTML code to include the files and invoke them in the appropriate place.


This approach makes both the HTML code and the PHP code easy to read and, on the other hand, because the HTML code needs to be constantly updated, and this separate method ensures that the daemon is not corrupted.
Unlike the front-end program, the background program is more stable, structured, rarely changed, so should be carefully designed and managed. In fact, in the design of the program, invest a lot of time is worth, "now trees, after the cool", in the future design work will be able to easily use the background program now written.

http://www.bkjia.com/PHPjc/318846.html www.bkjia.com true http://www.bkjia.com/PHPjc/318846.html techarticle when writing a PHP program, some code is used to handle a number of transactions, such as the operation of the database, mathematical operations, etc., while some other code is just the results of the transaction is displayed, ...

  • 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.