PHP Calculator Using Eval

PHP Calculator Using Eval

Continuing my previous post Javascript Calculator Using Eval, in this post, I will try to share also to make a simple PHP Calculator Using Eval. Unlike Javascript Calculator Using Eval PHP Calculator Using Eval using php code that reside inside the form. We will use form tag that targeted to the file it self.

The HTML and PHP code:

<form action="" method="post">
<input type="text" name="query" />
<input type="submit" value="calculate" />
<input type="text" disabled value="<?php if(isset($_POST['query'])){eval('echo '.$_POST['query'].';');} ?>"/>

Make sure to save the file with the extension .php. Otherwise it wont work.

Our PHP Calculator Using Eval here have similar function with Javascript Calculator Using Eval that can calculate a simple calculation such as addition, reduction, multiplication and division. It also can handle parenthesis.

The different of this PHP Calculator Using Eval with Javascript Calculator Using Eval is the  PHP Calculator Using Eval has to reload the page to calculate your inputted query, while the Javascript Calculator Using Eval is not reloading the page.

I wish this PHP Calculator Using Eval is useful for you.

Good Luck

Related Post:

Javascript Calculator Using Eval


2 responses to “PHP Calculator Using Eval

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: