Home > Backend Development > PHP Tutorial > PHP mortgage calculation

PHP mortgage calculation

不言
Release: 2023-03-28 19:04:02
Original
1903 people have browsed it

This article mainly introduces PHP mortgage calculation, which has certain reference value. Now I share it with everyone. Friends in need can refer to it.

  function debx()
  {
    $dkm   = 360; //贷款月数,20年就是240个月
    $dkTotal = 390000; //贷款总额
    $dknl  = 0.049; //贷款年利率
    $emTotal = $dkTotal * $dknl / 12 * pow(1 + $dknl / 12, $dkm) / (pow(1 + $dknl / 12, $dkm) - 1); //每月还款金额
    $lxTotal = 0; //总利息
    for ($i = 0; $i < $dkm; $i++) {
      $lx   = $dkTotal * $dknl / 12;  //每月还款利息
      $em   = $emTotal - $lx; //每月还款本金
      echo "第" . ($i + 1) . "期", " 本金:", $em, " 利息:" . $lx, " 总额:" . $emTotal, "<br />";
      $dkTotal = $dkTotal - $em;
      $lxTotal = $lxTotal + $lx;
    }
    echo "总利息:" . $lxTotal;
  }
    
    
  function debj()
  {
    $dkm   = 360; //贷款月数,20年就是240个月
    $dkTotal = 390000; //贷款总额
    $dknl  = 0.049; //贷款年利率
       
    $em   = $dkTotal / $dkm; //每个月还款本金
    $lxTotal = 0; //总利息
    for ($i = 0; $i < $dkm; $i++) {
      $lx   = $dkTotal * $dknl / 12; //每月还款利息
      echo "第" . ($i + 1) . "期", " 本金:", $em, " 利息:" . $lx, " 总额:" . ($em + $lx), "<br />";
      $dkTotal -= $em;
      $lxTotal = $lxTotal + $lx;
    }
    echo "总利息:" . $lxTotal;
  }
    
   debx(); 
  exit;
Copy after login

The above is the entire content of this article. Thank you. Everyone reads. Please pay attention to the PHP Chinese website for more information!

Related recommendations:

PHP filtering method to find prime numbers

The above is the detailed content of PHP mortgage calculation. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template