php - Warning: A non-numeric value encountered -


recently updated php 7.1 , start getting following error

warning: non-numeric value encountered in on line 29

here line 29 looks like

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

on localhost works fine..

any ideas how tackle or ?

it seems in php 7.1, warning emitted if non-numeric value encountered. see link.

here relevant portion pertains warning notice getting:

new e_warning , e_notice errors have been introduced when invalid strings coerced using operators expecting numbers or assignment equivalents. e_notice emitted when string begins numeric value contains trailing non-numeric characters, , an e_warning emitted when string not contain numeric value.

i'm guessing either $item['quantity'] or $product['price'] not contain numeric value, make sure before trying multiply them. maybe use sort of conditional before calculating $sub_total, so:

<?php  if (is_numeric($item['quantity']) && is_numeric($product['price'])) {   $sub_total += ($item['quantity'] * $product['price']); } else {   // error handling... } 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -