How to fix Warning: A non-numeric value encountered with PHP?

Spread the love

Sometimes, we want to fix Warning: A non-numeric value encountered with PHP.

In this article, we’ll look at how to fix Warning: A non-numeric value encountered with PHP.

How to fix Warning: A non-numeric value encountered with PHP?

To fix Warning: A non-numeric value encountered with PHP, we should make sure we’re doing arithmetic operations with numbers.

For instance, we write

$sub_total += (int) $item["quantity"] * (int) $product["price"];

to convert $item["quantity"] and $product["price"] to integers with (int) before we multiply them.

Conclusion

To fix Warning: A non-numeric value encountered with PHP, we should make sure we’re doing arithmetic operations with numbers.

Leave a Reply

Your email address will not be published.