[php-src] Issue #7895: Uncaught TypeError: Unsupported operand types: string * string in
| From: | iluuu1994 | Date: | Thu, 06 Jan 2022 13:57:53 +0000 |
| Subject: | [php-src] Issue #7895: Uncaught TypeError: Unsupported operand types: string * string in | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-238820@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7895
Comment Author: iluuu1994
@tolgahanacar
> <8 PHP Mathematical operations can be done with string expressions.
Yes, before PHP 8 all non-numeric strings in arithmetic operations could get cast to
0.
This could lead to detrimental bugs, especially when dealing with currencies like you are. If you
look at my comment [here](https://github.com/php/php-src/issues/7895#issuecomment-1006565805), you
can use filter_var to convert the value to a number. If the value turns out not to be a
number it's converted to false, in which case you can decide what to do yourself
(abort, use a default number, whatever is appropriate).