HTML Tutorial

This is a set of HTML tutorial. If you want to know web designing or blogging or other related to this filed, You must know HTML.

CSS Tutorial

As a web designer, you probably spend more time working with text than any other element.

PHP tutorial

We have already added PHP tutorial and Database Tutorial.

Internet

The best ways to make money both online and offline as a student. Lots of original ideas on how to make money quickly and easily to boost your finances.

Video Tutorials

Not everyone learns by reading books! Often the best way is to watch someone else first.

Tuesday, December 2, 2014

How to Creating an easy calculator in PHP

Let's suppose, we would like to create an easy calculator and without using mysql. It is promising only by using “IF statement in PHP”. First you need to create a new file for writing the codes, and you can use Notepad or notepad++ for this reason, though I’ve used Notepad++ in this tutorial. Presently save the file and name it as “calculator.php”; save the file in the htdocs folder of your XAMPP Installation, because that is our root folder and we run files from that folder on our local server (Local host). Now for creating a calculator you need to first create a form in HTML and add some input tags. Here is the HTML code for the calculator, and we'll later on add PHP code to this:

f(isset($_POST['submit'])){
$value1 = $_POST['value1'];
$value2 = $_POST['value2'];
$action = $_POST['action'];
if($action=="+"){
echo "Your Answer is:
";
echo $value1+$value2;
}
if($action=="-"){
echo "Your Answer is:
";
echo $value1-$value2;
}
if($action=="*"){
echo "Your Answer is:
";
echo $value1*$value2;
}
if($action=="/"){
echo "Your Answer is:
";
echo $value1/$value2;
}
}
?>

Now check your online calculator in your browser, and retain information always open your PHP files using this address: localhost. Every now and then wrongly you directly click on the file which is inside a folder.


I hope you have enjoyed and learnt something new from this tutorial.