【文件属性】:
文件名称:php-formula-interpreter:php的公式解释器
文件大小:32KB
文件格式:ZIP
更新时间:2021-05-09 00:34:23
PHP
PHP的公式解释器
php的公式解释器
为什么要建这个图书馆?
一些用户可能想要执行一个简单的计算,并能够尽可能地更改它。 在使用库之前,可以使用eval函数。 但是此方法有两个主要缺点:
安全。 一个eval函数正在评估一个php脚本。 Php是一种非常强大的语言,对于用户来说可能太强大了,特别是在用户想要注入恶意代码时。
复杂。 对于不懂编程语言的人来说,PHP也很复杂。 相反,最好解释一个类似于excel的公式。
它是如何工作的 ?
首先,创建FormulaInterpreter\Compiler的实例
$ compiler = new FormulaInterpreter \ Compiler ();
然后,使用compile()方法解析要解释的公式。 它将返回FormulaInterpreter\Executable的实例:
$ executable = $ comp
【文件预览】:
php-formula-interpreter-master
----src()
--------FormulaInterpreter()
----phpunit.xml.dist(704B)
----LICENSE(1KB)
----README.md(2KB)
----tests()
--------Command()
--------Parser()
--------CompilerTest.php(1KB)
----.gitignore(40B)
----composer.json(471B)