Google Calculator formats mathematical expressions in this way:
2+2/2 ---> 2 + (2 / 2) 2+2/2*PI ---> 2 + ((2 / 2) * PI)
In other words, brackets are added. Are there any similar PHP or JavaScript solutions to do the same?
Yes; The fastest and easiest way to not encode it yourself (for example, like Google) is using MathML .
Hope this helps!
Of course you can just request a calendar via curl + ajax / postback? the result is a json array with left, right, error, etc.
Example request: http://www.google.com/ig/calculator?q=5*9%2B%28sqrt+10%29^3%3D
php / curl sample: http://www.dynamicguru.com/php/currency-conversion-using-php-and-google-calculator-api/#more-285