>  기사  >  백엔드 개발  >  PHP 프로세스 제어 및 수학 연산

PHP 프로세스 제어 및 수학 연산

墨辰丷
墨辰丷원래의
2018-06-08 15:06:393382검색

이 글은 주로 PHP 프로세스 제어와 수학 연산을 소개합니다. 관심 있는 친구들이 참고하면 좋겠습니다.

이 문서의 예에서는 다음과 같이 PHP에서 세후 급여를 계산하는 방법을 설명합니다. 0 13880

23000 15680

26000 17480
29000 19280
32000 21080
35000 22880
38000 24680
41000 26480
44000 28280
47000 3 0080
50000 31805

<?php
function after_sleep($salary,$housefund_ratio=0.1,$person_insurance_ratio=.08,$medical_insurance_ratio=.04)
{
  $base = 3500;
  $housefund = $salary * $housefund_ratio; //.10 .8
  $person_insurance = $salary * $person_insurance_ratio;
  $medical_insurance = $salary * $medical_insurance_ratio;
  $insurance=($housefund + $person_insurance +$medical_insurance);
  if ($salary - $insurance  < $base ){
    return $salary - $insurance;
  }
  $taxable_income= ($salary - $insurance -$base );
   if ($taxable_income <=1500 ){
    $ratio = .03;
    $deduct = 0;
  }else if ($taxable_income > 1500 && $taxable_income <=4500) {
    $ratio = .1;
    $deduct = 105;
  }else if ($taxable_income > 4500 && $taxable_income <=9000) {
    $ratio = .2;
    $deduct = 555;
  } else if ($taxable_income > 9000 && $taxable_income <= 35000) {
    $ratio = .25;
    $deduct = 1005;
  } else if ($taxable_income > 35000 && $taxable_income <= 55000) {
    $ratio = .3;
    $deduct = 2755;
  }
  $tax = $taxable_income * $ratio-$deduct;
  $money = $salary -$insurance-$tax;
  return $money;
}
echo "税前\t税后\n";
for ($i=5000;$i<=50000;$i+=3000)
echo $i,"\t",after_sleep($i,.08),"\n";


Summary
: 위 내용이 이 글의 전체 내용입니다. 모두의 공부에 도움이 됩니다.


관련 권장 사항:

PHP에서 Yii 프레임워크의 기본 사용법

PHP에서 재귀를 구현하는 세 가지 기본 방법

PHP에서 이미지에 텍스트 워터마크를 추가하는 4가지 방법

위 내용은 PHP 프로세스 제어 및 수학 연산의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.