Home > Backend Development > PHP Tutorial > Research on the reasons why PHP files do not write closing tag conventions

Research on the reasons why PHP files do not write closing tag conventions

伊谢尔伦
Release: 2023-03-02 20:14:02
Original
1455 people have browsed it

When I first started writing PHP code, I wanted to write PHP closing tags. Later, I changed my habit and stopped writing PHP closing tags. I first came across this concept from Drupal, and I was a little uncomfortable at first - why not write a closing tag? This feels very imperfect, and very uncomfortable for people with obsessive-compulsive disorder! Later, I encountered problems caused by closing tags at work, so I started not writing closed tags.

For pure PHP files, the reason why closing tags are not written is to prevent extra spaces, tabs, etc. after the closing tags. These extra characters will be output when rendering the page, causing page misalignment; it is also possible, You include another PHP file in a PHP file and use the header function, and in the other PHP file, because there are extra characters after the closing tag, the final page will report an error because the output is done before the header function. . Therefore, it is strongly recommended not to write closing tags in pure PHP files.

This is also mentioned in Zend’s code specification: http://framework.zend.com/manual/1.12/en/coding-standard.php-file-formatting.html


Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template