File: README.md

Recommend this page to a friend!
  Classes of Walk  >  PHP Math Formula Parser  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Math Formula Parser
Parse and evaluate formulas with variables
Author: By
Last change:
Date: 1 year ago
Size: 1,313 bytes
 

 

Contents

Class file image Download

formula

Latest Stable Version Build Status Total Downloads

Simple mathematical expression parser

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist seregas/formula "*"

or add

"seregas/formula": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

$parser = new \socialist\formula\Formula('2 + 3 * 2,65 + 25 - 26');
$parser->calculate(); // 8.95

Also in the formula you can use variables:


$parser = new \socialist\formula\Formula('2 + 3 * p + 25 - 26');
$parser->setVariable('p', 2,65);
$parser->calculate(); // 8.95

And insert comments like /.../, [...] or {...}:


$parser = new \socialist\formula\Formula('2 + 3 p / price */ + 25 - 26');
$parser->setVariable('p', 2,65);
$parser->calculate(); // 8.95


For more information send a message to info at phpclasses dot org.