Addition in PHP


Q. Write a PHP program for addition of two numbers

<?php
// Define two numbers
$num1 = 10;
$num2 = 20;

// Perform addition
$sum = $num1 + $num2;

// Display the result
echo "The sum of $num1 and $num2 is: $sum";
?> 

Q. Write an algorithm for addition of two numbers in PHP

1. Start
2. Define two variables: num1 and num2
3. Add the numbers and store the result in sum = num1 + num2
4. Print the value of sum
5. End 



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.