FUNZIONI PHP
bccomp()
Questa funzione compara due numeri.
Sintassi:
bccomp(x,y,z)
Dove avremo
x ed
y i numeri da confrontare,
mentre
z il numero di decimali di cui tener conto.
Risultato:
Se x>y otterremo
1
Se x<y otterremo
-1
Se x=y otterremo
0
Esempio:
P.s. Se volete inserire un numero con decimali, ricordatevi di
inserirlo con il punto e non con la virgola.
Codice esempio:
<form action="index.php" method="get">
Inserisci il primo numero
<input type="text" name="funz" size="4" maxlength="10"><br>
Inserisci il secondo numero
<input type="text" name="funz2" size="4" maxlength="10"><br>
Inserisci il numero di decimali
<input type="text" name="funz3" size="2" maxlength="2"><br>
<input type="submit" value="Calcola">
</form>
<br>
<?
$funz=$_GET['funz'];
$funz2=$_GET['funz2'];
$funz3=$_GET['funz3'];
$funz4=bccomp($funz,$funz2,$funz3);
echo"Il risultato è ".$funz4;
?>