Calculations

PHP program to multiply two numbers

PHP program to multiply two numbers

In this tutorial, we will discuss the concept of  PHP program to multiply two numbers

In this topic, we are going to learn how  to write a program to multiply two numbers  in  PHP programming language

Find product of two numbers

Program to multiply two numbers

Find product of two numbers – #1

In this program, the user declare two integer variables $x and $y. Then two numbers are multiplied using multiplication(*) operator. finally  the result is displayed on the screen

Program 1

<?php  //php script
$num1=30;
$num2=15;
$mul=$num1*$num2;
echo "product: ".$mul;
//exit php
?>

When the above code is executed, it produces the following result

product: 450

 

Find product of two numbers – entered by user – #2

In this program, the user asked to enter two numbers(by passing input value to form).  Then two numbers are multiplied using * operator to find product and the result is displayed on the  screen

program 2

<form method = "post">
Enter 1st number
<input type = "number" name="number1"/><br><br>
Enter 2nd number
<input type = "number" name="number2"/><br><br>

<input type = "submit" name="submit" value="multiply"/><br>
</form>

<?php
if(isset($_POST['submit']))
{
    $number1=$_POST['number1'];
    $number2=$_POST['number2'];
    $mul=$number1 * $number2;
    echo "The multiplication of $number1 and $number2 is: ".$mul;
    
}

?>

When the above code is executed, it produces the following result

program to multiply two numbers

 

 

Find product of two numbers – entered by user – #3

In this program, the user asked to enter two numbers(by passing input value to form).  Then two numbers are multiplied using * operator to find product and the result is displayed on the  screen

program 3

<form>
Enter 1st number
<input type = "number" name="number1"/><br><br>
Enter 2nd number
<input type = "number" name="number2"/><br><br>

<input type = "submit" name="submit" value="multiply"/><br>
</form>

<?php
    if(isset($_GET['number1']) && isset ($_GET['number1'])){
    $number1=intval($_GET['number1']);
    $number2=intval($_GET['number2']);
    
    echo "The multiplication of $number1 and $number2 is: ";
    echo $number1*$number2;
    
    }
?>

When the above code is executed, it produces the following result

Program to multiply two numbers

 

Similar post

Java program to multiply two numbers

C program to multiply two numbers

C++ program to multiply two numbers

Python program to multiply two numbers

 

Java program to multiply two floating-point numbers

C program to multiply two floating-point numbers

C++ program to multiply two floating-point numbers

Python program to multiply two floating-point numbers

 

Java program to multiply two numbers using methods

C program to multiply two numbers using function

C++ program to multiply two numbers using function

Python program to multiply two numbers function

 

PHP addition of two numbers

PHP subtraction of two numbers

PHP addition of two numbers using function

PHP subtraction of two numbers using function

Function to subtract two numbers in PHP
Function to multiply two numbers in PHP
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

How to find reverse number using method in Java

How to find reverse number using method In this article, we will discuss the concept…

20 hours ago

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago