开发者

PHP: compute 2 variables product

开发者 https://www.devze.com 2023-01-07 08:55 出处:网络
how can I compute the product between these 2 quantities开发者_如何学Go in php ? This is what I\'ve tried, but it doesn\'t work

how can I compute the product between these 2 quantities开发者_如何学Go in php ?

This is what I've tried, but it doesn't work

<?php echo (uc_price($price_info, $context) * $product->qty); ?>

thanks


Does uc_price($price_info, $context) and $product->qty return a integer? its more likely that uc_price($price_info,$context) return a array, object or something else. make sure it return a integer. Also its better to cast those value into integer/float before multiplication e.g:

<?php echo (int)uc_price($price_info,$context) * (int)$product->qty; ?>

or cast them to float(price is more likely to be float:

<?php echo (float)uc_price($price_info,$context) * (float)$product->qty; ?>


Echo the variables to determine if they're numbers:

<?php
  echo "<br>" . uc_price($price_info, $context) . "<br>" . $product->qty;
?>

Then debug your code(check the part(s) that does not return a number).

0

精彩评论

暂无评论...
验证码 换一张
取 消