Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Sum two numbers in PHP with HTML input form

<!DOCTYPE html>
<html>
<head>
    <title>Sum</title>
</head>
<style>
    body {
        background: linear-gradient(110deg, #fdcd3b 60%, #ffed4b 60%); 
    }
    .container {
        width: 400px;
        margin: 0 auto;
        background-color: #eee;
        padding: 20px;
        border-radius: 10px;
        box-shadow: 0px 0px 10px #000;
    }
    .container1{
        width: 100px;
        margin: 0 auto;
        background-color: #eee;
        padding: 20px;
        border-radius: 10px;
        box-shadow: 0px 0px 10px #000;
        text-align: center; 
    }
    .container input {
        width: 80%;
        padding: 10px;
        margin-bottom: 10px;
    }
    .container button {
        width: 80%;
        padding: 10px;
        margin-bottom: 10px;
    }
    .container .result {
        width: 100%;
        padding: 10px;
        margin-bottom: 10px;
    }
     form{
            width: 300px;
            margin: 0 auto;
            text-align: center;
     }
        input{
                width: 200px;
                height: 30px;
                margin: 10px;
                border: 1px solid #ccc;
                border-radius: 5px;
                padding: 5px;
        }
        .container{
            width: 300px;
            margin: 0 auto;
            text-align: center;
            background-color: #ccc;
        }
        button{
            margin: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            padding: 5px;
            background-color: #34568B;
            width: 200px;
            color: #fff;
            font-weight: bold;
            font-size: 20px;
            padding: 10px;
            width: 200px;
        }
        button:hover{
            margin: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
            background-color: #FF6F61;
            width: 200px;
            color: #fff;
            font-weight: bold;
            font-size: 20px;
            padding: 5px;
            width: 200px;
        }
 </style>
<body>
<div class="container">
<form>
    <input type="number" name="num1" placeholder="Number 1" />
    <input type="number" name="num2" placeholder="Number 2" />
    <button input type="submit" value="CHECK THE SUM">submit</button>
</form>
</div>

<?php
if (isset($_GET['num1']) && isset($_GET['num2'])) {
 
    $num1 = $_GET['num1'];
    $num2 = $_GET['num2'];
    $sum = $num1 + $num2;
    echo "<div class='container1'>";
    echo "<div class='result'>";
    echo  $num1 . " + " . $num2 . " = " . $sum;
}
?>
 
</body>
</html
Comment

add two numbers in php

<?php  
$x=15;  
$y=30;  
$z=$x+$y;  
echo "Sum: ",$z;  
?>  
Comment

sum two numbers in php

<?php  
$x=10;  
$y=20;  
$z = $x + $y;  
echo "Sum of x and y : ". $z;  
?>
Comment

Write a php program to perform sum of two numbers

 <?php 
$x=10; 
$y=10; 
$z=$x+$y; 
echo "result is",$z; 
?> 
Comment

adding two numbers in php

<?php

function addTwoNumbers($number1, $number2){
    echo "Result: ",$number1+$number2;
}

addTwoNumbers(100, 125);
?>
Comment

php sum 2 arrays

<?php
  $i = 1;
  $j = 2;
 $a = $i + $j;
echo "The sum of i and j will be" . $a;
?>
Comment

PREVIOUS NEXT
Code Example
Php :: laravel sanctum Provoking tokens 
Php :: wp_register_script 
Php :: php api connection 
Php :: laravel model isdirty 
Php :: insert array values in database using codeigniter 
Php :: cakephp login session 
Php :: reverse string php 
Php :: sanctum 
Php :: php number multiple of 
Php :: upgrade php version to 7.4 or higher 
Php :: variables in php 
Php :: how to start the index from 1 in php? 
Php :: PHP executable not found. Install PHP 7 and add it to your PATH or set the php.executablePath setting 
Php :: php input onchange 
Php :: php json pretty print and slash 
Php :: laravel create custom route file 
Php :: year dropdown loop in php 
Php :: php get json objects by key without indez 
Php :: get percentage rating in laravel 
Php :: how to get favicon with Goutte php 
Php :: php include file from another folder 
Php :: windows list registered applications 
Php :: laravel digits between does not working 
Php :: close route in laravel 
Php :: Before Action methoond in Yii 1 controller 
Php :: install pdo mysql in alpine-apache php 5.6 
Php :: xss=removed 
Php :: Error : Call to undefined method IlluminateNotificationsChannelsMailChannel::assertSentTo() 
Php :: sometimes validation in laravel 
Php :: Laravel unique with Validation with multiple input value 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =