Ratings | | Unique User Downloads | | Download Rankings |
Not yet rated by the users | | Total: 98 | | All time: 9,836 This week: 206 |
Version | | License | | PHP version | | Categories |
taschenrechner 1.0.6 | | Free for non-comm... | | 7 | | PHP 5, Math |
|
Description | | Author |
This package can calculate the result of multiple math operations.
It can process multiple math operations with numeric parameters.
A separate class implements each operation. Currently the package supports operations like addition, subtraction, multiplication, division, power, sin, cos, tan, root and grouping of operations. Innovation Award
 November 2021
Winner
Prize: One official elePHPant Plush Mascott |
Some applications need to be able to perform calculations with dynamic operations and values that are only available at the time when the application code executes.
This package provides a solution for dynamically composing math operations depending on a logic defined by the applications using values for the operations variables that the application determines at execution time.
Manuel Lemos |
| |
 |
|
Innovation award
 Nominee: 3x
Winner: 1x |
|
Example
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use Taschenrechner\Classes\Calculator;
use Taschenrechner\Classes\Operationen\Klammer;
use Taschenrechner\Classes\Operationen\KlammerZu;
use Taschenrechner\Classes\Operationen\Wurzel;
use Taschenrechner\Classes\Operationen\Tan;
use Taschenrechner\Classes\Operationen\Cosinus;
use Taschenrechner\Classes\Operationen\Sinus;
use Taschenrechner\Classes\Operationen\Potenz;
use Taschenrechner\Classes\Operationen\Multiplikation;
use Taschenrechner\Classes\Operationen\Division;
use Taschenrechner\Classes\Operationen\Addition;
use Taschenrechner\Classes\Operationen\Subtraktion;
use Taschenrechner\Classes\Concatinator;
session_start();
unset($_SESSION["exception"]);
unset($_SESSION["ergebnis"]);
unset($_SESSION["term"]);
$term = $_GET["term"];
try {
//Initialisiere den Taschenrechner
$calculator = new Calculator();
//Füge Operationen hinzu:
//Deklariere einen Term und übergebe den Term
$calculator->addOperation(5, new Klammer($calculator, new Concatinator()));
$calculator->addOperation(0, new KlammerZu($calculator, new Concatinator()));
$calculator->addOperation(4, new Tan($calculator, new Concatinator()));
$calculator->addOperation(4, new Cosinus($calculator, new Concatinator()));
$calculator->addOperation(4, new Sinus($calculator, new Concatinator()));
$calculator->addOperation(3, new Wurzel($calculator, new Concatinator()));
$calculator->addOperation(3, new Potenz($calculator, new Concatinator()));
$calculator->addOperation(2, new Multiplikation($calculator, new Concatinator()));
$calculator->addOperation(2, new Division($calculator, new Concatinator()));
$calculator->addOperation(1, new Addition($calculator, new Concatinator()));
$calculator->addOperation(1, new Subtraktion($calculator, new Concatinator()));
$ergebnis = $calculator->calculate($term);
//Sende das Ergebnis zurück zu Index.php
$_SESSION["ergebnis"] = $ergebnis;
$_SESSION["term"] = $term;
header("Location: index.php");
} catch(Exception $exception) {
//Sende den Fehler zurück zur Index.php
$_SESSION["exception"] = $exception->getMessage();
}
$_SESSION["term"] = $term;
header("Location: index.php");
?>
|
Details
A Calculator created in PHP
This is a PHP Calculator which can take a math operation and return the result.
Currently the package supports operations like addition, subtraction, multiplication, division, power, root and grouping of operations.
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.