Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c
JavaScript Program for multiplying Two Numbers | 4 different ways

PHP multiplication of two numbers: PHP program

Posted on July 11, 2022July 18, 2022

Table of Contents

  • PHP multiplication of two numbers: PHP program
    • Code to product  of two numbers in PHP
      • Find product of two numbers  – #1
      • Find product of two numbers  – #2
      • Find product of two numbers  using form- #3
      • Find product of two numbers  using form- #4
    • Related

PHP multiplication of two numbers: PHP program

In this article, we will discuss the concept of PHP multiplication of two numbers

In this post, we are going to learn how to write a program to find  product of two numbers in PHP language

Code to product  of two numbers in PHP

Find product of two numbers  – #1

Program 1

  • Start HTML tag
  • Start PHP script
  • Declare and initialize two integer variable
  • Calculate product of given two numbers
  • Display result on the screen
  • Exit PHP
  • Close HTML tag

In this program, the user initialize the values to variables and calculates the product of the given numbers using multiplication(*) operator. And then the result is displayed on the screen.

Program 1

<html>
<head>
<title> Multiplication of two numbers</title>
</head>
<body>
<h3>Multiply two number using form</h3>
<?php  //php script
$num1=25;
$num2=12;
$mul=$num1*$num2;
echo "product: ".$mul;
//exit php
?>
</body>
</html>

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

Multiply two number using form

product: 300

 

Find product of two numbers  – #2

In this program, the user initiates the values to variables and calculates the product of the given numbers using multiplication(*) operator. then the result is assigned to another variable ($res) and the the result is displayed on the screen using that variable

Program 2

  • Start HTML tag
  • Start PHP script
  • Declare and initialize two integer variable
  • Calculate product of given two numbers
  • Assign the result to third variable
  • Display result on the screen
  • Exit PHP
  • Close HTML tag
<html>
<head>
<title> Multiplication of two numbers</title>
</head>
<body>
<h3>Multiply two number using form</h3>
<?php  //php script
$num1=5;
$num2=15;//declare variables
$mul=$num1*$num2;//calculate product of two numbers
$res="Product: ".$mul;
//the output asigned to third variable
echo $res;//print the result on the screen
//exit php
?>
</body>
</html>

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

Multiply two number using form

Product: 75

 

Find product of two numbers  using form- #3

In this program, the user is entered the values to variables using form(the program Asks input from the user to form) and calculates the product of the given numbers using multiplication(*) operator and the result is assigned to third variable ($mul) .finally the result is displayed on the screen using third variable.

  • Create HTML form
  • Exit HTML form
  • Start PHP script
  • Exit PHP

program 3

<html>
<head>
<title> Multiplication of two numbers</title>
</head>
<body>
<h3>Multiply two number using form</h3>
<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;
}
?>
</body>
</html>

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

 

 

Find product of two numbers  using form- #4

In this program, the user is entered the values to variables using form(the program Asks input from the user to form) and calculates the product of the given numbers using multiplication(*) operator and the result is assigned to third variable ($mul) .finally the result is displayed on the screen using third variable.

  • Create HTML form
  • Exit HTML form
  • Start PHP script
  • Exit PHP

program 4

<html>
<head>
<title> Multiplication of two numbers</title>
</head>
<body>
<h3>Multiply two number using form</h3>
<form>
Enter 1st number
<input type = "number" name="num1"/><br><br>
Enter 2nd number
<input type = "number" name="num2"/><br><br>

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

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

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

PHP multiplication of two numbers: PHP program
Multiplication of 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

 

PHP addition of two numbers

PHP addition of two numbers using function

PHP subtraction of two numbers

PHP subtraction of two numbers using function

 

Related

Recent Posts

  • Multiply two numbers in Java using scanner| 5 different ways
  • 5 different ways to Divide two numbers in Java using scanner
  • Learn 8 Ways to Subtract Two Numbers Using Methods in Java
  • 10 ways to subtract two numbers in Java
  • Java Code Examples – Multiply Two Numbers in 5 Easy Ways
  • How to Divide two numbers in Java| 5 different ways

tag

Addition (8) Array (38) C++ language (91) C language (98) c sharp (23) Division (8) Function (29) if else (32) Java language (108) JavaScript (5) loops (138) Multiply (8) Oop (2) patterns (66) PHP (13) Python Language (38) Subtraction (9) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2026 Code for Java c | Powered by SuperbThemes