
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
43 lines
1.7 KiB
Plaintext
43 lines
1.7 KiB
Plaintext
== Why is this an issue?
|
|
|
|
While it is not inherently wrong to use the closing PHP tag, developers often choose to omit it to minimize the chances of encountering issues and to follow established best practices and coding standards.
|
|
|
|
=== What is the potential impact?
|
|
|
|
There are a few reasons developers should avoid using the closing PHP tag `?>` at the end of a file:
|
|
|
|
If a developer accidentally adds whitespace or any other characters after the closing PHP tag, it can cause PHP to automatically start output buffering.
|
|
This can lead to unexpected behavior when trying to modify headers or perform redirects because headers need to be sent before any content.
|
|
|
|
Some frameworks and coding standards explicitly discourage the use of the closing PHP tag to ensure compatibility and portability across different PHP environments and versions.
|
|
|
|
Following a consistent coding style and adhering to best practices are important for code readability and maintainability.
|
|
Many coding standards, such as the PER (PHP Evolving Recommendation), recommend omitting the closing PHP tag for the reasons mentioned above.
|
|
|
|
== How to fix it
|
|
|
|
Omitting the closing PHP tag can help prevent the injection of unintended output.
|
|
It also eliminates the need to worry about removing or handling the closing tag when modifying or concatenating multiple PHP files, making code maintenance easier.
|
|
|
|
== Resources
|
|
=== Documentation
|
|
|
|
* https://www.php.net/manual/en/language.basic-syntax.phptags.php[PHP Manual - PHP tags]
|
|
|
|
=== Standards
|
|
|
|
* https://www.php-fig.org/per/coding-style/#22-files[PER Coding Style 2.0 - Files]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Remove this closing tag "?>".
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|