Advantages of not writing closed labels in php

Source: Internet
Author: User

This concept was first introduced in Drupal and was a bit unaccustomed at the beginning-why not write a closed tag? This is not perfect. It is not suitable for people with obsessive-compulsive disorder! Later, I encountered a problem caused by TAG closure in my work, so I started not to write the closed tag.
I have read some articles and summarized the PHP closed labels as follows:
Benefits:If this is a program that is included by others and does not have this Terminator, it can reduce many problems, such as header, setcookie, and session_start, there cannot be output before these actions, if you are not careful When invisible characters (extra spaces and line breaks) are added to the backend to destroy the page display, the "Header already sent" error will be reported. If you do not write it, this problem will not occur. In addition, you can directly move the cursor to the end and then program.
Disadvantages:In the dreamweaver view mode, it is a mess.
The official explanation for PHP closed tags is: PHP closed tags "?> "PHP analyzer is optional in PHP. However, if you use closed tags, any developer, user, or the spaces after inserting the closed tag in the FTP application may cause redundant output, php errors, and subsequent output failures or blank pages. Therefore, all php files should omit this php closed tag and insert a comment to indicate that this is the bottom of the file and locate the relative path of the file in this application. This will help you determine that the file has been ended rather than deleted.
This is also mentioned in Zend's code specification: http://framework.zend.com/manual/1.12/en/coding-standard.php-file-formatting.html
Sample Code:
Improper:
Copy codeThe Code is as follows:
<? Php
Echo "Here's my code! ";
?>
Appropriate:
Copy codeThe Code is as follows: <? Php
Echo "Here's my code! ";
/* End of file myfile. php */
/* Location:./system/modules/mymodule/myfile. php */

Therefore, if it is a pure php code file, should it be omitted?> End identifier.

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.