Recently, witnessed an odd behavior on a WordPress site I maintain.
- As logged in Administrator, and submit button would lead to blank screen, execute but not forward to next page.
- As logged in Administrator, deleting a user, when selecting delete all contents, this would lead to a blank screen, execute but not forward. Refreshing screen, says user does not exist.
- As a user, of site any submission would lead to a blank screen.
It was annoying and took me some time to find the issue, checked the error_log indicated the problem.
1 | [18-Feb-2023 07:14:33 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/bond007/public_html/wp-content/themes/James/ functions.php:1) in
|
But after I restored a previous version of functions.php I could not find any differences, using WinMerge
I opened the file in VSCode, could not find anything on line 1 wrong.
I opened the file in Notepad++, could not find anything on line 1 wrong.
Then I opened the file in Fred an open-source hex editor.
So then I remember, allong time ago, in far off land, I got BOMed.
Issue:
You should ensure that the included files do not start with a BOM.
You may also find that the BOM causes problems for an ordinary PHP page. When sending custom HTTP headers the code to set the header must be called before output begins. A BOM at the start of the file causes the page to begin output before the header command is interpreted, and may lead to error messages and other problems in the displayed page.
Src: https://www.w3.org/International/questions/qa-byte-order-mark
Solution:
Change Encoding type in Notepad++ to UTF-8. Then save.
Tips:
Pay attention to the bottom of your editor for the file type.
No comments:
Post a Comment