PHP Classes

PHP AJAX Calculator: Perform calculations and get the results via AJAX

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 366 All time: 6,848 This week: 49Up
Version License PHP version Categories
ajaxcalculator 1.0.0GNU General Publi...5PHP 5, Math, AJAX
Description 

Author

This class can perform calculations and get the results via AJAX.

It can take parameters values from a form and perform simple calculations with those values like addition, subtraction, multiply, divide, logical_and, logical_or and power.

The class can return the results and a summary of the operation in XML format so it can be easily processed by client side JavaScript code that can update the user interface to the display the results.

Innovation Award
PHP Programming Innovation award nominee
June 2019
Number 2


Prize: 30 Days Free Access to O'Reilly Safari Learning Platform
AJAX requests are useful to develop applications on which the browser interacts with the server without reloading the current page.

This class can present a simple calculator that performs several types of operations and display the results using AJAX requests to perform the necessary calculations on the server side.

Manuel Lemos
Picture of Pierre-Henry Soria
  Performance   Level  
Name: Pierre-Henry Soria <contact>
Classes: 47 packages by
Country: United Kingdom
Age: 33
All time rank: 37416 in United Kingdom
Week rank: 43 Up1 in United Kingdom Up
Innovation award
Innovation award
Nominee: 17x

Winner: 3x

Example

<?php
/**
 * @author Pierre-Henry Soria <pierrehenrysoria@gmail.com>
 * @copyright (c) 2015, Pierre-Henry Soria. All Rights Reserved.
 * @license MIT License <http://www.opensource.org/licenses/mit-license.php>
 * @link http://github.com/pH-7/
 */

if (isset($_GET['op'], $_GET['lho'], $_GET['rho']))
{
    try
    {
        require
'Calculator.php';
        echo (new
Calculator($_GET['op'], $_GET['lho'], $_GET['rho']))->xmlOutput(); // PHP 5.4 syntax, access on instantiation
   
}
    catch (
Exception $oE)
    {
       
file_put_contents('exception.log', $oE->getMessage() . PHP_EOL . PHP_EOL, FILE_APPEND); // Create a log file
       
return false;
    }
}


Details

PHP Ajax Calculator

What is That?

Description

That Ajax Web application is an online PHP Ajax Calculator working with jQuery and OOP PHP (Calculator class).

P.S. This is a very simple project. You are free to improve it or change it! Good luck ;-)

Who is the Author?

Pierre-Henry Soria

How to Contact the Author?

By email at: pierrehenrysoria [[AT]] gmail [[D0T]] com

What is the License?

This script is under MIT License


  Files folder image Files (6)  
File Role Description
Accessible without login Plain text file ajax.js Data Auxiliary data
Plain text file Calculator.php Class Class source
Accessible without login Plain text file call.php Example Example script
Accessible without login Plain text file common.css Data Auxiliary data
Accessible without login HTML file index.html Doc. Documentation
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:366
This week:0
All time:6,848
This week:49Up