Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/05/2002, 19:50
syburgos
 
Fecha de Ingreso: mayo-2002
Ubicación: concepcion
Mensajes: 21
Antigüedad: 21 años, 11 meses
Puntos: 0
duda con calculadora PHP

encontre el sgte script en PHP, para crear una calculadora ,el unico problema es que los resultados de las funcicones avanzadas las da en Radianes.¿Como hago que el resultado sea "Normal"?.

aqui va el codigo...


<html>
<head>
<title>Wargoat's Calculator Script</title>
</head>
<body>
<?php

//variables being posted
$t1 = $HTTP_POST_VARS['n1'];
$t2 = $HTTP_POST_VARS['n2'];
$t3 = $HTTP_POST_VARS['R1'];
$b1 = $HTTP_POST_VARS['D1'];
$b2 = $HTTP_POST_VARS['n3'];

//first commands
if($t3 == a)
$ta = $t1 + $t2;

if($t3 == s)
$ta = $t1 - $t2;

if($t3 == m)
$ta = $t1 * $t2;

if($t3 == d)
$ta = $t1 / $t2;

if($t3 == pow)
$ta = pow($t1, $t2);

//2nd commands
if($b1 == abs)
$ta = abs($b2);

if($b1 == sin)
$ta = sin($b2);

if($b1 == cos)
$ta = cos($b2);

if($b1 == tan)
$ta = tan($b2);

if($b1 == asin)
$ta = asin($b2);

if($b1 == acos)
$ta = acos($b2);

if($b1 == atan)
$ta = atan($b2);

if($b1 == sqrt)
$ta = sqrt($b2);

if($b1 == log)
$ta = log($b2);

if($b1 == log10)
$ta = log10($b2);

if($b1 == rad2deg)
$ta = rad2deg($b2);

if($b1 == deg2rad)
$ta = deg2rad($b2);

if($b1 == dec2bin)
$ta = decbin($b2);

if($b1 == bin2dec)
$ta = bindec($b2);

if($b1 == dec2hex)
$ta = dechex($b2);

if($b1 == hex2dec)
$ta = hexdec($b2);

if($b1 == dec2oct)
$ta = decoct($b2);

if($b1 == oct2dec)
$ta = octdec($b2);

?>
<table width="250" border="1" cellspacing="0" cellpadding="0" bgcolor="#0066FF">
<tr bgcolor="#003399" valign="top" align="center">
<td><font color="#CCCCCC" face="Verdana, Arial, Helvetica, sans-serif" size="2">Wargoat's
Calculator Script</font></td>
</tr>
<tr align="center" valign="top">
<td>
<form action=simpcalc.php method="post">
<font color="#CCCCCC" face="Verdana, Arial, Helvetica, sans-serif" size="2">
N1:
<input type="text" name="n1" size="8">
N2:
.........