You think you did nothing on your WordPress website and suddenly you got such error?
Warning: “continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”? in /…/wp-includes/pomo/plural-forms.php on line 210
Warning: Cannot modify header information – headers already sent by (output started at /…/wp-includes/pomo/plural-forms.php:210) in /…/wp-includes/pluggable.php on line 1216
You are not alone. I got such error myself on blogs I didn’t touch for years.
It took me awhile to find a solution, but at last I found it and I want to share my findings. Hopefully it will be helpful for you too.
I will list other solutions I found online which didn’t help me, but may be will be useful to others.
What didn’t work
- The first suggestion I found by googling this error message was to replace corrupted source files. I.e. download fresh WordPress setup files and replace my installation except wp-content folder and wp-config.php file. I tried it, but it didn’t help at all.
- The second solution was to edit function.php file. I definitely didn’t want to go this way and edit WP core files. So I was looking for other solution.
What did work
After some intensive search I read one recommendation regarding downgrading PHP version on server hosting WordPress site. When I saw that comment I remembered. Last year the only thing I did for that site was upgrading PHP to the latest version 7.3. This was recommended by WordPress requirements.
I did follow these recommendations and updated PHP to 7.3 for all my websites in bulk . Because I did it in bulk I didn’t check all my sites. My bad.
So I had combination of PHP 7.3 and WP 4.9.3 which didn’t work. I needed to reverse it back with hope it will work. 7.1 was the lowest PHP version available on my web host. I didn’t have other choice but to choose it. It worked! I could login to my WP admin panel. The first thing I did – upgraded WordPress version from 4.9.3 to 5.2.3.
After WP upgrade I switched again PHP version to the latest available v7.3. Checked my website and it still was fine.
Conclusion
I can not guarantee it will work for everybody, but these are the steps I took to fix an error on my sites:
- Downgrade PHP version at your web hosting.
- Login into your WordPress admin dashboard
- Upgrade WordPress version to the latest available
- Switch PHP version to the highest available
I hope it will help to solve your problem. Please comment bellow if this solution was helpful and tell us which WP and PHP versions were causing a problem.
Jamal
This worked for me. Thank you so much!
Amateur Blogger
You are welcome.
tobias
it worked for me !! thank you very much
Amateur Blogger
Glad to hear it.
Stephen
I appreciate!
Fărcaş Gelu Dănuţ
Thank you! Work well!
Amateur Blogger
You are welcome
John O
Thanks, you saved my ass dude!!
Amateur Blogger
glad to hear that.
David
Worked for me. from 7.4.3 back to 7.3.15 Thanks a lot…
Amateur Blogger
perfect
Donato
Worked! I had to roll back to 5.6 (7,1 was not enough)!
Thank you
Amateur Blogger
Perfect, Donato! 7.1 was the lowest PHP version available on my web host.
Haseeb
This doesn’t work for me 🙁
Amateur Blogger
Haseeb,
Which hosting you are using? What is WP version? What is PHP version?
ali maleki
thanks. it works.
Amateur Blogger
Great!
Ivan
This worked for me, thanks!
Amateur Blogger
Great!
Mike
working after downgrade to PHP 7.1 ! thanks mate !
Amateur Blogger
Perfect! You are welcome 🙂
Remek
Unfortunatelly it doesn’t work…
Amateur Blogger
Which hosting you are using? What is WP version? What is PHP version?
Remek
I’m using polish hosting nazwa.pl. WP version is 5.4. PHP version is 7.4.
I did all the things you wrote about.
Amateur Blogger
And you didn’t have problems with WP 5.3? At what moment it became broken?
Remek
There was a problem also with 5.3 WP version. I can’t determine when exactly this problem occurred.
Amateur Blogger
It is hard to suggest anything. The only advice would be experiments as I did with my site. Disabling all plugins usually is one of first thing I did. Test your website with default theme and etc.
Gina
What if your wordpress site is already running the latest version – 5.4? I tried to downgrade my php version into 7.1 but it did not work for me. Also tried version php 5.6
Amateur Blogger
Which your actions caused this error? After php upgrade? After WP upgrade? It is hard to comment anything without knowing which steps made your site to crash.
Steve
Thanks so much for this! I wouldn’t have known what to do otherwise! Downgrading to PHP 7.1 and upgrading to WP 5.4 worked fine, but upgrading to PHP 7.3 causes an error page to briefly show before being replaced by the actual page. Updating plugins also shows the error, but it does all appear to work.
I’m now at WP 5.4 and PHP 7.2 and that seems to be all ok.
Amateur Blogger
Glad to hear you found WP/PHP combination which works.
renee
You just saved my live lol
thanks a lot!!
Amateur Blogger
U r welcome
Peer K
Worked a charme, problem was with WP 4.9.x and PHP 7.3, tied first a new install and lost access to wp-admin login.
Downgrading PHP to version 7.1 let me log into the new installed WP and upgrade to 5.4.1 then logout and upgraded to PHP 7.3 again. All good now. Thanks!
Amateur Blogger
perfect
Durgesh
Dear All
M also faced the below error when uploading new plugin “WpDataTables” with PHP version 7.3
“Warning: “continue” targeting switch is equivalent to “break”.”
As per the guidance of this page I tried to change the PHP version.
And now it is glad to tell you that it works with PHP version 7.2 and also 7.4 but when I tried to change back to version 7.3, it again shows this error.
Conclusion: This Plugin only not compatible with PHP 7.3.
Amateur Blogger
I never used WpDataTables plugin, but I am glad you found a solution at last.
Babs19
Thank you so much!!! It worked!!! Saved my ass 😉
Amateur Blogger
U r welcome
David Claes
that did it ! great thx !
noemie
It worked the first time, thank you so much!!!!
Margaret Agard
I had wordpress 5.4.2 and downgraded from pho7.3 to php7.0 error is now gone. Thank you!
Daniel
Excelente ! Funcionou Perfeitamente.
BMA
I hate to be ‘that guy’, but this is really bad advice and I’d strongly recommend it NOT be followed. Here’s why:
If your production/live site is echoing PHP errors publicly (rather than sending them to a log file), your site is misconfigured and insecure. You should edit php.ini (or find the server maintainer who can) to turn off visible php errors.
Downgrading PHP, or WordPress, or both, to a lower, older and more insecure level in order to avoid a simple PHP warning is a dreadful idea. It’s like replacing your secure steel front door with one made out of cardboard simply because the hinges on the steel one sometimes squeak. It makes no sense.
Downgrading is not a fix. It’s bad hack that hides the problem by downgrading the entire site and server to less secure and out of date versions. Don’t do it. At some point you will be forced to upgrade and deal with the issue properly.
I admit this error is certainly a nuisance because the incorrect use of ‘continue’ in switches is used widely in some popular WordPress plugins (eg some WooCommerce extensions). For whatever reason the developers have failed to implement a very simple code fix (namely, replace ‘continue’ with ‘break’). However, the way for site admins to address the problem is:
1) Turn off visible `error_reporting` on your production sites in php.ini by making sure this line is present and enabled:
display_errors = Off
2) Send errors and warnings to eg /var/log/php error log by making sure the following settings are present and set:
log_errors = On
error_log = /path/to/php_errors.log
(You can turn off error logs if you want, but that’s probably a bad idea as you won’t be able to debug when something unexpected happens.)
3) If you don’t have control of PHP settings in php.ini, insist the server admin turns sets display_errors = Off. If they refuse, find a host who knows what they’re doing.
4) Add or set these four lines in your wp-config.php somewhere before the ‘That’s all, stop editing!’ line:
define (‘WP_DEBUG’, false);
define (‘WP_DEBUG_LOG’, false);
define (‘WP_DEBUG_DISPLAY’, false);
@ini_set (‘display_errors’, 0);
(This won’t stop php errors being logged to the server logs, but will help stop errors being visible or logged to a separate log file by WordPress.)
5) If you want to prevent the “continue” error swamping your error_logs, you can try to switch off code warnings in php.ini by making sure this line is present:
error_reporting = E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING
(This means, log all errors, except less important ones like code standards, notices and warnings.)
Unfortunately, these errors may still be logged due to code in your WordPress site which changes your error_reporting levels at runtime. This is an annoying habit by plugin coders.
6) Bug the plugin developers to fix their code standards.
Amateur Blogger
Hi BMA,
Did you read carefully my advice? It seems you didn’t.
Nobody suggest to downgrade it and leave it.
It is a matter of couple minutes. You downgrade, update and upgrade again immediately.
I will copy/paste it just for you:
1. Downgrade PHP version at your web hosting.
2. Login into your WordPress admin dashboard
3. Upgrade WordPress version to the latest available
4. Switch PHP version to the highest available
Though your comment about not showing PHP errors publicly I think will be useful for some readers here.
Seth Lofgreen
This worked, thank you!
Alan
IT WORKED
Martine
It worked. Thank you so much for this explanation.
Amateur Blogger
Great, Martine.
Marcia
Yeah! This the best advice! To change php for 7.1. Thx a lot!
shivam
If I removed this
WP Content Copy Protection & No Right Click
plugin then the error went away
Amateur Blogger
Great and good to know that. Which WP and PHP versions do you have?
Nicks
Worked, thanks.
Amateur Blogger
glad to hear that.