Jump to content

Recommended Posts

wheee

[code]
<?php  $self = $_SERVER['PHP_SELF'];
          $operator = $_POST['radio'];
          $value1 = $_POST['value1'];
          $value2 = $_POST['value2'];
if(isset($operator)){
  if($operator == "*"){
    $final_value = $value1 * $value2;
  }
  elseif($operator == "/"){
    $final_value = $value1 / $value2;
  }
  elseif($operator == "+"){
    $final_value = $value1 + $value2;
  }
  elseif($operator == "-"){
    $final_value = $value1 - $value2;
  }
} else {
    $final_value = "";
}

?>

<form method="post" action="<?php echo $self; ?>">
First Value <input type="text" name="value1" />
<br />
+ <input type="radio" name="radio" value="+" />
- <input type="radio" name="radio" value="-" />
x <input type="radio" name="radio" value="*" />
/ <input type="radio" name="radio" value="/" />
<br />
Second Value <input type="text" name="value2" />
<br />
<input type="submit" value="Calculate" />
<br /><br />
Final Value: <input type="text" value="<?php echo $final_value; ?>" />
</form>
[/code]

see how what good use i put my time to....

hooray.
Link to comment
https://forums.phpfreaks.com/topic/25893-bored-again-made-a-calculator/
Share on other sites

[quote author=Daniel0 link=topic=113561.msg461546#msg461546 date=1162450725]
Here is a challenge for you then: Try to make a calculator where you can enter simple expressions and make it calculate it... Eg: 1+2*5
[/quote]

I suspect that's not quite what you're thinking of -

[code]<?php
echo(1+2*5);
?>[/code]

Shows 11. Just as it should.

[quote author=Crayon Violent link=topic=113561.msg461547#msg461547 date=1162450918]
or make a graphing calculator using the gd library.
[/quote]

+10 ninja points if you get this one. That would be super cool.
[quote author=neylitalo link=topic=113561.msg461552#msg461552 date=1162451710]
[quote author=Crayon Violent link=topic=113561.msg461547#msg461547 date=1162450918]
or make a graphing calculator using the gd library.
[/quote]

+10 ninja points if you get this one. That would be super cool.
[/quote]

hmm i have this sneaky feeling that someone has read that, and is hacking up some GD scripts as we speak...
[quote author=redbullmarky link=topic=113561.msg461599#msg461599 date=1162464896]
hmm i have this sneaky feeling that someone has read that, and is hacking up some GD scripts as we speak...
[/quote]

It's just a good thing that I don't have to give anything tangible. :) I heart imaginary rewards. Except when I'm getting them.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.