Jump to content

Transformar percentagem em numero decima


mota77
 Share

Recommended Posts

se quiseres mais elaborado, tenta assim:

<form action="" method="get">
<input type="text" name="perc">
<input type="submit" value="Enviar">
</form>
<? 
$perc = $_GET['perc'];
if ($perc < 100) {
$dec = $perc / 100;
echo $dec;
}
else
{
echo "Erro, número não válido!";
}
?>

por que razão uma percentagem tem que ser menor do que 100? (é que nem precisa de ser menor ou igual...)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.