Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Galera a minha calculadora basica funciona de boa no Linux mais na hora que executo ela no windows não!
Estou utilizando o metodo GET e o erro da na linha 63 onde não consigo emprimir o resultado!
<!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">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Calculadora</title>
</head>
<?php
$valor1 = $_GET['valor1'];
$valor2 = $_GET['valor2'];
$opcao = $_GET['opcao'];
$total = $_GET['total'];
if ($opcao == somar){
$total = ($valor1 + $valor2);
echo "$total";
}
elseif ($opcao == subtrair){
$total = ($valor1 - $valor2);
echo "$total";
}
elseif ($opcao == multiplicar){
$total = ($valor1 * $valor2);
echo "$total";
}
elseif ($opcao == dividir){
$total = ($valor1 / $valor2);
echo "$total";
}
else {
echo "Opção invalida";
}
echo "<img src='calculadora 1.jpg'>";
?>
<body>
<form action="calculadora_teste.php" method="get">
<table>
<tr>
<td><h4>Calculadora</h4></td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>
<tr>
<td>Valor1
<input type="text" name="valor1" id="valor1" size="5" maxlength="5" />
<td><select name="opcao" id="opcao">
<option>Selecione</option>
<option value="somar">+ somar</option>
<option value="subtrair">- subtrair</option>
<option value="multiplicar">* multiplicar</option>
<option value="dividir">/ dividir</option>
</select>
Valor2
<input type="text" name="valor2" id="valor2" size="5" maxlength="5" />
=
<input type="text" name="total" id="total" value="<?= $total ?>" size="5" maxlength="10"/></td>
</tr>
<tr>
<td><input type="submit" name="igual" id="igual" value="calcular" /> </td>
</tr>
</table>
</form>
</body>
</html>Carregando comentários...