Código :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="post" action="operacion.php"> <p> <input type="text" name="campo1" id="campo1" /> </p> <p> <input type="text" name="campo2" id="campo2" /> </p> <p> <input type="radio" name="operacion" id="radio" value="+" /> + <input type="radio" name="operacion" id="radio2" value="-" /> - <input type="radio" name="operacion" id="radio3" value="/" /> / <input type="radio" name="operacion" id="radio4" value="*" /> *</p> <p> <input type="submit" name="button" id="button" value="Submit" /> </p> </form> </body> </html>
operacion.php
Código :
<?PHP $operacion=$campo1." ". $operacion." ". $campo2; echo $operacion; ?>
el resultado de esto es:
2 + 2 como string, pero no me hace la operacion deberia quedar como resultado 4, que me sugieren, gracias