Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Removing unneccessary closing tags to prevent potential issues. #223

Merged
merged 3 commits into from
Jun 15, 2023

Conversation

SRNT-GG
Copy link
Contributor

@SRNT-GG SRNT-GG commented Jun 9, 2023

Removing closing tags when no further output is expected or done.

Reason why, for those unaware;
The PHP closing tag (?>) is optional at the end of PHP files, and there are a few reasons why it's often recommended to omit it:

Avoiding accidental whitespace or characters: Including the closing tag can potentially introduce unintended whitespace or characters after the closing tag. If any whitespace or characters are outputted after the closing tag, it can cause issues, such as headers being sent to the browser prematurely, which may lead to "headers already sent" errors.
Improved code readability: Omitting the closing tag can help prevent accidental whitespace or new lines being added after the closing tag, which could cause problems when PHP interacts with other content types like HTML, CSS, or JavaScript. It also helps maintain a consistent coding style throughout the project.
Mitigating potential security risks: Omitting the closing tag eliminates the possibility of having trailing white spaces or new lines that could cause issues, such as inadvertently exposing sensitive information like user credentials or generating unwanted output in certain scenarios

Removing closing tags when no HTML or other output comes after the last PHP codeblock.
@SRNT-GG SRNT-GG changed the title Part 1 Removing unneccessary closing tags to prevent potential issues. Jun 9, 2023
@SRNT-GG SRNT-GG changed the title Removing unneccessary closing tags to prevent potential issues. WIP - Removing unneccessary closing tags to prevent potential issues. Jun 9, 2023
@slawkens
Copy link
Owner

slawkens commented Jun 11, 2023

Sooo, WIP or should I merge? ;)

@SRNT-GG
Copy link
Contributor Author

SRNT-GG commented Jun 11, 2023

I think I got them all acctually, should be safe to merge.

@slawkens
Copy link
Owner

Alright!

@slawkens slawkens merged commit 8d10082 into slawkens:master Jun 15, 2023
1 check passed
slawkens added a commit that referenced this pull request Jun 15, 2023
…#223)

* Part 1

Removing closing tags when no HTML or other output comes after the last PHP codeblock.

* Further removals

* nothing

---------

Co-authored-by: slawkens <slawkens@gmail.com>
slawkens added a commit that referenced this pull request Jun 18, 2023
…#223)

* Part 1

Removing closing tags when no HTML or other output comes after the last PHP codeblock.

* Further removals

* nothing

---------

Co-authored-by: slawkens <slawkens@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants