PHP does not write the benefits of closing tags _php tutorial

Source: Internet
Author: User
Tags closing tag drupal zend
This concept was first approached from Drupal and was a bit unaccustomed at first-why not write a closed tag? It's not perfect, it's not suitable for people with obsessive-compulsive disorder. Later, in the work of the problem caused by the closure of the label, it began not to write closed tags.
For some articles, a summary of the PHP closing tag 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 can not have output before, if accidentally added to the?> behind the invisible character (extra space, NewLine characters, such as 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.
Disadvantages:In Dreamweaver's view mode, it's a mess.
The official explanation for the PHP closing tag is that the 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.
This is also mentioned in the Code specification for Zend: http://framework.zend.com/manual/1.12/en/coding-standard.php-file-formatting.html
code Example:
Improper:
Copy CodeThe code is as follows:
echo "Here ' s my code!";
?>
Suitable for:
Copy CodeThe code is as follows: 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, you should omit the?> end identifier.

http://www.bkjia.com/PHPjc/736809.html www.bkjia.com true http://www.bkjia.com/PHPjc/736809.html techarticle This concept was first approached from Drupal and was a bit unaccustomed at first-why not write a closed tag? It's not perfect, it's not suitable for people with obsessive-compulsive disorder ...

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