This project is a web-based scientific calculator built using PHP, JavaScript, HTML, and CSS. The calculator supports basic arithmetic operations (addition, subtraction, multiplication, division), as well as advanced mathematical functions like exponentiation, square roots, logarithms, and percentages.
Basic Arithmetic Operations: Addition, Subtraction, Multiplication, Division Advanced Functions: Exponentiation, Square Root, Logarithm, Percentage User-friendly Interface Responsive Design
calculator/ │ ├── index.php ├── calculate.php ├── addition.php ├── subtraction.php ├── multiplication.php ├── division.php ├── exponentiation.php ├── sqrt.php ├── logarithm.php ├── percentage.php ├── styles.css ├── scripts.js └── README.md
git clone https://github.com/Allanotieno254Backup/calculator-using-php
cd calculator
If you are using XAMPP, move the project folder to the htdocs directory. mv calculator /path/to/xampp/htdocs/
Open XAMPP and start the Apache server. Access the calculator: Open your web browser and navigate to http://localhost/calculator.
Basic Arithmetic: Use the buttons on the calculator interface to perform addition (+), subtraction (-), multiplication (*), and division (/).
· Use the ^ button for exponentiation. · Use the √ button for square roots. · Use the log button for logarithms (base 10). · Use the % button to calculate percentages.
· Use the C button to clear the display. · Use the DEL button to delete the last character.
index.php The main entry point of the calculator. It includes the form for user input and the display area. It also contains the JavaScript functions for handling user interactions.
Handles the form submission and determines which mathematical operation to perform based on the user input. It includes the appropriate PHP file for the operation and returns the result.
Performs the addition operation. It takes the user input, splits it into numbers, and calculates the sum.
Performs the subtraction operation. It takes the user input, splits it into numbers, and calculates the difference.
Performs the multiplication operation. It takes the user input, splits it into numbers, and calculates the product. division.php Performs the division operation. It takes the user input, splits it into numbers, and calculates the quotient.
Performs the exponentiation operation. It takes the user input, splits it into the base and exponent, and calculates the power.
Performs the square root operation. It takes the user input, extracts the number, and calculates the square root.
Performs the logarithm operation. It takes the user input, extracts the number, and calculates the base-10 logarithm.
Performs the percentage operation. It takes the user input, splits it into numbers, and calculates the percentage.
Contains the CSS styles for the calculator interface. It ensures a responsive and user-friendly design.
Contains the JavaScript functions for handling user interactions and updating the display in real-time.
If the calculator is not working as expected, check the following:
· Ensure PHP is correctly installed and configured. · Check the PHP error log for any errors.
· Open the browser's developer tools and check the console for any JavaScript errors.
· Ensure the web server is running and accessible.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
· Thanks to the developers of PHP, JavaScript, HTML, and CSS for providing the tools to build this project. · Special thanks to the open-source community for their valuable resources and support.