Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#55882 closed enhancement (invalid)

Regarding avoid PHP start end tag

Reported by: bhavinp311's profile bhavinp311 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords:
Focuses: docs, coding-standards Cc:

Description

Hello WordPress,

Please refer to this troubleshooting doc:
https://wordpress.org/support/article/faq-troubleshooting/#how-do-i-solve-the-headers-already-sent-warning-problem

Here you explain the Wrong and Correct code.
Please refer to this screenshot: https://prnt.sc/W7yRGUb1VsGG

But in many of your core themes, there is so many Wrong codes.
Please refer to this screenshot: https://prnt.sc/s90ubl1I0ju3

Thanks!

Change History (6)

#1 @mukesh27
2 years ago

  • Component changed from General to Bundled Theme
  • Focuses coding-standards added

#2 @SergeyBiryukov
2 years ago

  • Keywords close added

Hi there, welcome to WordPress Trac! Thanks for the ticket.

That troubleshooting section only applies to user-editable files that are loaded before any HTTP headers are sent and any output is displayed on the screen, e.g. wp-config.php or the theme's functions.php file (outside of a function).

The section does not apply to theme templates, which are loaded after the HTTP headers are sent, so there is nothing wrong with code like that in the bundled themes.

If anyone has ideas on clarifying this in the documentation, please feel free to suggest. Thanks!

#3 @bhavinp311
2 years ago

Hello there,

Thank you for clarifying!

This ticket was mentioned in Slack in #docs by joyously. View the logs.


2 years ago

#5 follow-up: @TJNowell
2 years ago

I certainly think this could be clarified better in the document itself with some simple changes so that this confusion doesn't happen in the future

I'd suggest making the following changes:

  • change the get into got in the description
  • add a space at "<?phptag" -> "<?php tag"

And changing:

This could be true about some other file too, so please check the error message, as it will list the specific file name where the error occurred (see “Interpreting the Error Message” below).

to

This can also happen in other edited PHP files that are not theme templates, so please check the error message, as it will list the specific file name where the error occurred (see “Interpreting the Error Message” below).

This should clarify things better in that document.

#6 in reply to: ↑ 5 @SergeyBiryukov
2 years ago

  • Focuses docs added
  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Replying to TJNowell:

I certainly think this could be clarified better in the document itself with some simple changes so that this confusion doesn't happen in the future

Thanks! I have made the suggested changes.

Closing, as this was not an issue with WordPress core or bundled themes, but rather a documentation issue that should now be addressed.

Note: See TracTickets for help on using tickets.