Why would one omit the close tag?

前端 未结 14 1575
旧巷少年郎
旧巷少年郎 2020-11-21 06:18

I keep reading it is poor practice to use the PHP close tag ?> at the end of the file. The header problem seems irrelevant in the following context (and this

14条回答
  •  心在旅途
    2020-11-21 07:06

    There are 2 possible use of php code:

    1. PHP code such as class definition or function definition
    2. Use PHP as a template language (i.e. in views)

    in case 1. the closing tag is totally unusefull, also I would like to see just 1 (one) php open tag and NO (zero) closing tag in such a case. This is a good practice as it make code clean and separate logic from presentation. For presentation case (2.) some found it is natural to close all tags (even the PHP-processed ones), that leads to confution, as the PHP has in fact 2 separate use case, that should not be mixed: logic/calculus and presentation

提交回复
热议问题