Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Exemplo de cálculo de IRRF com Funções
<?php
function calculaIRRF($salario) {
if($salario < 1903.98) {
$desconto = 0;
}
elseif($salario <= 2826.65){
$desconto = 7.5;
}
elseif($salario <= 3751.5) {
$desconto = 15;
}
elseif($salario <= 4664.68) {
$desconto = 22.5;
}
else {
$desconto = 27.5;
}
return $salario * $desconto / 100;
}
echo calculaIRRF(1500) . "\n";
echo calculaIRRF(2000) . "\n";
echo calculaIRRF(3000) . "\n";
echo calculaIRRF(4000) . "\n";
echo calculaIRRF(5000) . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.