How to usethe * Operator in PHP
The simplest way to multiply two numbers in PHP is by using the multiplication operator *.
PHP
<?php function multiplyNums( $num1 , $num2 ) { $result = $num1 * $num2 ; return $result ; } // Driver code $num1 = 5; $num2 = 8; $product = multiplyNums( $num1 , $num2 ); echo "Products: $product" ; ?> |
Output
Products: 40
PHP Program to Multiply Two Numbers
Given two numbers, the task is to multiply both numbers using PHP. Multiplying two numbers is a fundamental arithmetic operation.
Examples:
Input: x = 10, y = 5
Output: 50
Input: x = 40, y = 4
Output: 160
Table of Content
- Using the * Operator
- Using the bcmul() Function
- Using Custom Function for Multiplication