admin管理员组文章数量:1122832
After update to PHP8 I get errors:
PHP Parse error: Unmatched '}' in /public_html/wp-content/themes/theme/functions/a_critical_css.php on line 44
The file looks like:
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
function add_my_critical_css(){ ?>
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
color: #717a8f;
padding-top: 44px;
line-height: 1.3;
background: #fff;
-webkit-tap-highlight-color:rgba(255, 255, 255, 0.1);
}
</style>
<?php
} //this is line 44
add_action('my_critical_css','add_my_critical_css');
The problem is that if I downgrade PHP, website works perfect. When I upgrade... I get critical Wordpress error.
Could somone help me how to solve the problem?
Thank you in advance.
After update to PHP8 I get errors:
PHP Parse error: Unmatched '}' in /public_html/wp-content/themes/theme/functions/a_critical_css.php on line 44
The file looks like:
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
function add_my_critical_css(){ ?>
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
color: #717a8f;
padding-top: 44px;
line-height: 1.3;
background: #fff;
-webkit-tap-highlight-color:rgba(255, 255, 255, 0.1);
}
</style>
<?php
} //this is line 44
add_action('my_critical_css','add_my_critical_css');
The problem is that if I downgrade PHP, website works perfect. When I upgrade... I get critical Wordpress error.
Could somone help me how to solve the problem?
Thank you in advance.
Share Improve this question edited Aug 4, 2023 at 1:35 YourManDan 4342 silver badges12 bronze badges asked Aug 3, 2023 at 19:15 TereskaTereska 313 bronze badges 2- 1 Copy and pasted your code into a WordPress install on PHP 8, and did not receive any error. Only recommendation I can make is to cleanup your code to be more readable: putting PHP tags on their own lines, indenting properly, etc. – Caleb Commented Aug 3, 2023 at 19:36
- Is this the entire file, or just a section of it? There's nothing wrong with this code as far as I can see, but if there's more to the file there may be an issue with earlier parts of it. – YourManDan Commented Aug 3, 2023 at 20:00
1 Answer
Reset to default 0I'm having the same exact issue. Same message in PHP 8 but not in PHP 7.4. The code is properly indented, ect. and can't find a single issue.
本文标签: fatal errorWhy PHP Parse unmachet after update to PHP8
版权声明:本文标题:fatal error - Why PHP Parse unmachet after update to PHP8? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736307837a1933450.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论