Problems with boolean calculator

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
NeverSeenMan
Forum Newbie
Posts: 1
Joined: Sun Jun 25, 2006 6:30 am

Problems with boolean calculator

Post by NeverSeenMan »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello.
I've created a simple boolean calculator, but it doesn't work properly: if answer is "false", it doesn't show an answer. Where is the problem? This is the program:

Code: Select all

<DOCTYPE  html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org.TR/xhtml/DTD/xhtml-strict.dtd">
<html>
<head>
 <meta http-equiv="content-type" content="text/html;charset=utf-8"  />
 <title>Boolean calculator</title>
</head>
<body>
  <form action="#" method="get">
   <input type="text" name="input" value="<?php echo $_GET['input']; ?>" />
   <input type="submit" value="&raquo;" />
  </form>
  <pre>
<?php
    echo eval('return ('.$_GET['input'].');');
?>
  </pre>
  </body>
</html>
Thanks for your answers. NeverSeenMan


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Code: Select all

<?php

	echo $_GET['input'];
And please use the

Code: Select all

and [syntax="(sql|css|html)"] tags.
Post Reply