Why sometimes PHP does not write a closing tag terminator

Source: Internet
Author: User
Tags closing tag
Why does PHP sometimes not write closed tag terminator?



Find some information, everyone on the PHP closed tag summary is as follows:

Benefits: If this is a program that someone else contains, without this terminator, you can reduce a lot of problems, such as: header, Setcookie, session_start These actions must not have output, if accidentally added to the?> behind the invisible character (extra space , newline characters) and other broken page display, will be reported "Header already sent" error, do not write the words will not have this problem. Alternatively, you can move the cursor directly to the end and then program.

Cons: In Dreamweaver view mode, it's a mess.

The official explanation for the PHP closing tag is: PHP closed tag?> in PHP is optional for PHP parser. However, if you use a closed tag, any space behind the closed tag by a developer, user, or FTP application may cause extra output, PHP errors, output that cannot be displayed, and blank pages. Therefore, all PHP files should omit this PHP closed tag, and insert a note to indicate that this is the file's bottom and locate the file in the relative path of the application. This will help you to make sure that the document is over and not truncated.

Improper:


echo "Here ' s my code!";

?>

Suitable for:




echo "Here ' s my code!";

/* End of File myfile.php */

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






Therefore, if it is pure PHP code, you should omit the?> end identifier.
  • 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.