How to combine expressions in PHP?

To indicate the best way to combine expressions in PHP we will show you two clear examples below. As you might have already noticed the variable $price in the first example (5.1) is set on 1.21 * the variable $subtotal. This means the $subtotal value will be multiplied by 1.21 (the vat). Next, on the second line, the variable $price is rounded off to two decimals. The second example (5.2) contains exactly the same execution, but in this example though both expressions have been combined into one single expression.



Was this useful?