Why sometimes php does not write a closed tag Terminator?

Source: Internet
Author: User
Why sometimes php does not write a closed tag Terminator? After looking for some information, we can summarize the PHP closed labels as follows: Advantages: if this is a program included by others, without this Terminator, it can reduce many problems, such: header, setcookie, and session_start cannot be output before these actions? & Gt; when invisible characters (extra spaces, line breaks) are added to the backend to destroy the page display, why does php sometimes not write a closed tag Terminator?



I found some information and summarized the PHP closed labels as follows:

Benefit: if this is a program 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.

Disadvantage: a mess in dreamweaver view mode.

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.

Improper:


Echo "Here's my code !";

?>

Appropriate:




Echo "Here's my code !";

/* End of file myfile. php */

/* Location:./system/modules/mymodule/myfile. php */






Therefore, should php code 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.