denissimon / formula-parser

Parsing and evaluating mathematical formulas given as strings.
MIT License
76 stars 24 forks source link

Add more variables #4

Closed Meeshalk closed 5 years ago

Meeshalk commented 5 years ago

Is it possible to add more variables? If yes, then which letters/characters should not be used?

Very interesting code you have here, Thanks

denissimon commented 5 years ago

It's possible to do this by using the setValidVariables() method. Please see the examples of the section 4 (Test valid variables) in tests/FormulaParserTest.php Any letter other than "e" can be used as a variable. The letter "e" is always processed by the parser as a constant = 2.718.

Thank you!