Search code examples
phpecho

How do i multiply variables under echo quotations


I'm using echo to print a database info using html tags. So the entire statement is under quotation marks " ".

The user is buying some things so i have their price (for example in $price variable, really doesn't matter) and their number (in $number variable) and i'm trying to print out the total price of the bought item. It just prints out $price*$number expectedly, but i'm not sure what to try to get it to work the way i want it to.

I'm sure its rather simple i just can't think of a solution right now and its really bugging me :D


Solution

  • You should use string concatenation:

    echo "text text " . ($number * $price) . " text text"