Adding two numbers in php is a very simple task like you have done in other languages. You need to declare three variables or you can initialize them by assign value. like given below:
PHP Code:
- <?php
- //First variable initialization
- $FirstNumber = 10;
- //second variable initialization
- $SecondNumber = 20;
- //Third variable initialization with add operation
- $Sum = $FirstNumber + $SecondNumber;
- //printing the result that should be 30
- echo "Sum of Two number is :".$Sum;
- ?>
Now save this file with index.php inside your server's root directory. and open browser to see the result.
intphp.blogspot.com |