“Case statements followed by a semicolon (;) are deprecated” (PHP 8.5): what it means and the fix
Short answer
It’s a deprecation notice from PHP 8.5: a plugin or theme writes case 'compact'; with a semicolon where PHP expects a colon, case 'compact':. PHP has always accepted both, so the code still works; PHP 8.5 now flags the semicolon. The message appears when the file is loaded, once per such line, so a theme can produce several at once. The fix is one character per line. Update the plugin or theme, or send the message to its developer.
The message, exactly
A shop theme picks a product-grid layout with a switch whose case and default end in semicolons. PHP 8.4 runs it silently; PHP 8.5 runs it the same way and adds a notice per line:
wp-content/themes/shop-theme/inc/layout.php
<?php
$layout = 'compact';
switch ($layout) {
case 'compact';
echo "Compact product grid\n";
break;
default;
echo "Default product grid\n";
}
Compact product gridDeprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in /var/www/html/wp-content/themes/shop-theme/inc/layout.php on line 4
Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead in /var/www/html/wp-content/themes/shop-theme/inc/layout.php on line 7
Compact product gridphp.net, in the PHP 8.5 deprecations: “Terminating case statements with a semicolon instead of a colon has been deprecated.” (php.net)
What it means
In a switch, each case label ends with a colon: case 'compact':. PHP also accepted a semicolon there, so case 'compact'; worked too, and stayed in some plugins and themes for years. PHP 8.5 starts phasing that out. Nothing breaks now; the notice marks the lines to change.
Who fixes it
- Find the plugin or theme: the folder after
wp-content/plugins/orwp-content/themes/in the message. - Update it (Dashboard → Updates).
- Already on the latest version? Send one line of the message to its developer: the fix is one character per line.
- Meanwhile, keep notices off your pages: the WordPress debug log.
Found before you switch
The semicolons are in the code, so a check that reads code finds each line while your site still runs PHP 8.4:
The other PHP 8.5 changes, and which of them stop code: WordPress and PHP 8.5. To check a whole site for 8.5: the PHP 8.5 compatibility check.
Key takeaways
- A deprecation notice from PHP 8.5; the code works exactly as before.
- It concerns
case …;anddefault;in aswitch, written with a semicolon instead of a colon. - The notice appears when the file loads, once per line, even if that
switchnever runs. - The fix: replace
;with:after eachcaseanddefault. - A check that reads code finds every such line while your site runs PHP 8.4.
Frequently asked questions
Why did PHP accept a semicolon at all?
PHP’s manual documented it as an option: “It’s possible to use a semicolon instead of a colon after a case.” The colon is the usual form, and PHP 8.5 starts phasing out the alternative.
Is it urgent?
No. Nothing changes in how the code runs. Pass it to the developer so it’s fixed before a later PHP version stops accepting the semicolon.
Why do I see the notice on every page?
Because PHP checks it when it loads the file, and themes load their files on every page. Logging PHP messages instead of showing them keeps them off your pages.
Check your own site before you upgrade
CompatNav is a free WordPress plugin. It reads the code of your plugins and themes on your own server and tells you, in plain words, what will break and what will only show notices on the PHP version you choose. It never changes your code. It can’t see problems that only appear while code runs with real data, so a quick check of your site after the upgrade still matters.
Sources
About the code examples: each output is the real output of the code shown, run with the official PHP builds, without a php.ini, with all errors reported and displayed. Only the file path was replaced by a neutral server path.