VOOZH about

URL: https://www.geeksforgeeks.org/php/php-program-to-find-simple-interest/

⇱ PHP Program to Find Simple Interest - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PHP Program to Find Simple Interest

Last Updated : 23 Jul, 2025

Simple interest is the method to calculate the interest where we only take the principal amount each time without changing it for the interest earned in the previous cycle.

The formula to calculate Simple Interest is -

SI = P * R * T / 100

Where -

  • I is the interest.
  • P is the principal amount.
  • R is the rate of interest per annum.
  • T is the time in years.

In this article, we will explore how to calculate simple interest in PHP using different approaches.

Find Simple Interest using Inline Calculation

If you only need to perform the conversion once or in a specific context, you can do the calculation inline without defining a separate function.

Example: Illustration of program to find Simple Interest in PHP using inline calculations.


Output
Simple Interest: 450

Time Complexity: O(1)

Auxiliary Space: O(1)

Find Simple Interest using a Function

Defining a function to calculate simple interest is a reusable and modular way to perform the calculation. The simpleInterest( ) function takes the principal, rate, and time as arguments and returns the simple interest.

Example: Illustration of program to find Simple Interest in PHP using a function.


Output
Simple Interest: 450

Time Complexity: O(1)

Auxiliary Space: O(1)

Find Simple Interest Through User Input using HTML

In a more interactive scenario, you might want to calculate simple interest based on user input. This can be done using an HTML form to get the principal, rate and time as input and PHP to process the input.

Example: Illustration of program to find Simple Interest in PHP through User Input using HTML.

Output

👁 Simple-Interest

Time Complexity: O(1)

Auxiliary Space: O(1)

Comment
Article Tags:
Article Tags: