Today I moved a customer's WordPress blog to a subdomain because she wanted to run the site in a kind of internal area. The main domain should be redirected for this.
After I had set up the subdomain in Ionos and loaded all WordPress data into the new directory, I got the following message when I called up the login page:
Warning: "Continue" targeting switch is equivalent to "break".
This PHP error did not appear on the page before, which puzzled me.
Chapter in this post:
Error message appears from PHP 7.3
My suspicion that the error message had something to do with the PHP version of the hosting did not disappoint. As I saw in the hosting administration, the main domain was running PHP 7.2, while the subdomain was automatically set to PHP 7.4.
I then changed the PHP version of the subdomain to PHP 7.2 and lo and behold: the error had disappeared.
The change can be found at Ionos under “Hosting overview” and then in the “PHP” area.
The reason why a change was made in PHP can be found in the PHP Wiki:
In PHP, when continue is applied to a switch statement, it behaves just like break. In other languages, it would continue the surrounding loop instead. To avoid confusion, the RFC suggests that continues that affect switch be discarded and removed.
Adaptation of the code for PHP 7.3, 7.4 and following versions
Now there was a little problem: Ionos has announced that they will end support for PHP 7.2 in December 2020. The consequence would be that the error messages would pop up for my customer from one day to the next - not a good advertisement for her.
For this reason I was looking for a solution to revise your old theme so that it can be used for a few more years.
In order to fix the errors, you can now change a small command that you can find via the error message. One looks for a formulation similar to this:
switch ($ variable) {case "value": continue; }
and swaps the "continue" into a "break":
switch ($ variable {case "value": break;}
In this way you can gradually fix the errors and get your WordPress up and running again.
If you have any problems with your blog, please let me know. I offer a kind of WordPress emergency help with a friend and we help bloggers or companies when it comes to getting the website up and running again.
Related Articles
Jens has been running the blog since 2012. He acts as Sir Apfelot for his readers and helps them with technical problems. In his spare time he rides electric unicycles, takes photos (preferably with the iPhone, of course), climbs around in the Hessian mountains or hikes with the family. His articles deal with Apple products, news from the world of drones or solutions to current bugs.
Hello, I have this problem too, my pages show: Warning: “continue” targeting switch is equivalent to “break”. Did you mean to use “continue 2”? in /WWWROOT/235512/htdocs/wp-content/plugins/slimjetpack/modules/infinite-scroll/infinity.php on line 147
Will now try to solve this according to your instructions. LG from the beautiful Lower Rhine
Then good luck with the solution!