PHP Classes

How to Use a PHP Math Expression Parser to Convert a Math Expression to HTML: Render mathematics expressions on an HTML page

Recommend this page to a friend!

  Author Author  
Picture of Win Aung Cho
Name: Win Aung Cho is available for providing paid consulting. Contact Win Aung Cho .
Classes: 8 packages by
Country: Myanmar Myanmar
Age: 59
All time rank: 26954 in Myanmar Myanmar
Week rank: 93 Up1 in Myanmar Myanmar Up
Innovation award
Innovation award
Nominee: 3x


  Detailed description   Download Download .zip .tar.gz  
This package can render mathematics expressions on an HTML page.

It can take a string with a math expression and parse it to extract its structures.

The package also generates HTML to display the expression in a Web page.

Details

Math-Expression-to-HTML

Produce html code from the mathematic expression string Math-Expression-to-HTML

Demo Version

Visit following link and check demo in forum. Demo

Usage

First include the mathexphtml.php class in your file, and use the class as following to generate the HTML for the math expressions:

$expression = "a=sum(i=1,3)(23.5{vec}-(((cos(2+?/2)+asd9)^2)/4.5+sin(0.5?))/(20.06+?*(16))^2-26)";

$parser = new mathExpHtml($expression);
$parser->printTokens();
echo $parser->getHtml();

Features

Algorythm is very simple.

  • String is tokenized using `preg_split` into array of tokens,
  • Token types are value, alpha-numeric and operator.
  • Alpha numeric represents as a variable or function name.
  • There are some known functions such as summation sign sum(i=1, 5).
  • First tokens are simplify into simple expression inside the parenthesis.
  • Nested parenthesis are allowed.
  • Simple inside () are convert into html code using predefined css classes.
  • Precedence are common as following order, ^, *,/,+.-.
  • Multiple expressions of () may connected without operator eg., (3+a/4)(sin(0.5*?))
  • Vector variable can be used in written form enclosed with cali-bracket eg., {vec}

Contact

Contact me for comercial use via mail winaungcho@gmail.com.


  Classes of Win Aung Cho  >  How to Use a PHP Math Expression Parser to Convert a Math Expression to HTML  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog (1)  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: How to Use a PHP Math Expression Parser to Convert a Math Expression to HTML
Base name: math-expression-to-h
Description: Render mathematics expressions on an HTML page
Version: -
PHP version: 5
Licenses: Custom (specified in a license file)
GNU General Public License (GPL)
All time users: 81 users
All time rank: 9926
Week users: 1 user
Week rank: 381 Up
 
  Groups   Screenshots Screenshots   Rate classes User ratings   Applications   Files Files  

  Groups  
Group folder image HTML HTML generation and processing View top rated classes
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Math Math related classes. View top rated classes
Group folder image Parsers Programming language interpreters and format parsers View top rated classes

  Files folder image Screenshots  
mathexphtml.jpg
File Role Description
Accessible without login Image file mathexphtml.jpg Screen Screenshot


  Innovation Award  
PHP Programming Innovation award nominee
November 2022
Number 2
Some applications need to display mathematical expressions on Web pages in a way that professionals in mathematics are used to seeing those expressions.

A mathematical expression can be displayed on a Web page in several ways.

This package can render a mathematical expression using regular HTML.

Manuel Lemos

  User ratings  
Not yet rated by the users

  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Plain text file mathexphtml.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

Download Download all files: math-expression-to-h.tar.gz math-expression-to-h.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Plain text file mathexphtml.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

Download Download all files: math-expression-to-h.tar.gz math-expression-to-h.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.