VOOZH about

URL: https://www.geeksforgeeks.org/php/php-program-to-multiply-two-numbers/

⇱ PHP Program to Multiply Two Numbers - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PHP Program to Multiply Two Numbers

Last Updated : 28 Apr, 2025

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: 50Input: x = 40, y = 4
Output: 160

Approach 1: Using the * Operator

The simplest way to multiply two numbers in PHP is by using the multiplication operator *.


Output
Products: 40

Approach 2: Using the bcmul() Function

The bcmul() function is used for arbitrary-precision multiplication, providing accurate results for large numbers.

Output

Products: 96

Approach 3: Using Custom Function for Multiplication

Create a custom function that multiplies two numbers without using the * operator.


Output
Product: 96
Comment
Article Tags: