Reputation: 223
I am trying to multiply two values in php which gives me the error A non well formed numeric value encountered
Code:
$value = 2.5/100;
$totalvalue = $value * $totalvalue;
echo $totalvalue;
Upvotes: 2
Views: 13665
Reputation: 257
Use the code below :-
$totalvalue = 1.0 ; //Set $totalvalue and typecast to float
$value = 0.0 ;
$value = 2.5/100;
$totalvalue = $value * $totalvalue;
echo "<br>".$totalvalue;
Upvotes: 1
Reputation: 223
I forgot to typecast.
$value = 2.5/100;
$totalvalue = $value * (float)$totalvalue;
echo $totalvalue;
Upvotes: 2