Zacks Posted September 20, 2022 Share Posted September 20, 2022 How are doin' folks, When l update to PHP 8 - I get the following error: Fatal error: Uncaught TypeError: Unsupported operand types: int + string in <?php //the_field( "size" ); $internal = get_field('internal'); $terrace = get_field('terrace'); $garden = get_field('garden'); $total = $internal + $terrace + $garden; echo $total; ?> Quote Link to comment https://forums.phpfreaks.com/topic/315351-unsupported-operand-types-int-string-in-after-php-8-update/ Share on other sites More sharing options...
Solution Barand Posted September 20, 2022 Solution Share Posted September 20, 2022 Sounds like one or more of those get_fields is an empty string. Quote Link to comment https://forums.phpfreaks.com/topic/315351-unsupported-operand-types-int-string-in-after-php-8-update/#findComment-1600842 Share on other sites More sharing options...
ginerjm Posted September 20, 2022 Share Posted September 20, 2022 (edited) Your error message points to something type-related but your code doesn't seem to be doing anything involving types. Do you want to revise your post, or perhaps do a bit more describing and maybe even show us the error line the is being referenced in the whole message? Unless the error is tied to the last line. And what is this get_field function? Something in your script that you are not showing us? Edited September 20, 2022 by ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/315351-unsupported-operand-types-int-string-in-after-php-8-update/#findComment-1600843 Share on other sites More sharing options...
Barand Posted September 20, 2022 Share Posted September 20, 2022 12 minutes ago, ginerjm said: but your code doesn't seem to be doing anything involving types Yes it is $a = ''; $b = 2; echo $a + $b; with version 8, gives Quote Link to comment https://forums.phpfreaks.com/topic/315351-unsupported-operand-types-int-string-in-after-php-8-update/#findComment-1600845 Share on other sites More sharing options...
ginerjm Posted September 20, 2022 Share Posted September 20, 2022 Something new to us not-yet-on-8 users. As for get_field, just what is that? Is that V8 as well? Quote Link to comment https://forums.phpfreaks.com/topic/315351-unsupported-operand-types-int-string-in-after-php-8-update/#findComment-1600846 Share on other sites More sharing options...
Barand Posted September 20, 2022 Share Posted September 20, 2022 1 hour ago, ginerjm said: As for get_field, just what is that? Could be one of those really useful functions that comes free with a framework eg function get_field($key) { return $_GET[$key]; } Quote Link to comment https://forums.phpfreaks.com/topic/315351-unsupported-operand-types-int-string-in-after-php-8-update/#findComment-1600847 Share on other sites More sharing options...
ginerjm Posted September 20, 2022 Share Posted September 20, 2022 Maybe the OP will fill us in..... Quote Link to comment https://forums.phpfreaks.com/topic/315351-unsupported-operand-types-int-string-in-after-php-8-update/#findComment-1600850 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.