php does not write about the benefits of closing tags

  • 2021-01-14 05:46:05
  • OfStack

The original concept was introduced in Drupal, where 1 was a little uncomfortable at first -- why not write a closed tag? This feeling is not perfect ah, for people with obsessive-compulsive disorder is very uncomfortable! Later, I encountered problems caused by closing labels in my work, so I started not to write closed labels.
Referring to some articles, the PHP closing tag is summarized as follows:
Pros: If this is a program that is included by someone else and does not have this terminator, there are many, many problems that can be saved. For example: header, setcookie, session_start cannot be output before the action. > "Header already sent" error will be reported if an invisible character (extra space, newline character) is added to the end of the page to destroy the display. This problem will not occur if you do not write. Alternatively, you can simply move the cursor to the end and continue programming.
Cons: In dreamweaver view mode, 1 mess.
PHP Closed Label "PHP Closed Label" > "Profilers for PHP are optional in PHP. However, if a closed tag is used, any space inserted after a closed tag by a developer, user, or FTP application may cause extra output, php errors, subsequent output that cannot be displayed, and a blank page. Therefore, all php files should omit the php closing tag and insert a comment to indicate that this is the bottom of the file and locate the relative path of the file to the application. This will help you make sure the file is closed and not redacted.
In Zend code specification, also mentioned this point 1: http: / / framework zend. com manual / 1.12 / en coding - standard. php - file - formatting. html
Code example:
Inappropriate:


<?php
echo "Here's my code!";
?>

Appropriate:
<?php
echo "Here's my code!";
/* End of file myfile.php */
/* Location: ./system/modules/mymodule/myfile.php */

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


Related articles: