PHP数学方程函数 [英] PHP Maths Equation Function

查看:98
本文介绍了PHP数学方程函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真正想要的是一个数学方程函数,该函数接受一个表示和方程的字符串,并将答案计算为返回类型

What i am really looking for is a maths equation function that takes in a string representing and equation and calculates the answer as a return type

例如 ((((4 * 5)+ 6)* 2)/8"

For Example "(((4 * 5) + 6) * 2) / 8"

输出:6.5

所以在编码泪水之类的东西

So in coding tearms something like

print calc("(((4 * 5) + 6) * 2) / 8");

是否已经有一些天使建立的类或函数,或者我应该自己做

Is there already a class or a function that some angel has built or do i gota do it my self

谢谢

推荐答案

正如cloudhead所说的那样,已经解决了.

As cloudhead said, just fixed up.

$nums = "(((4 * 5) + 6) * 2) / 8";
eval("\$nums = $nums;");
echo $nums;

这篇关于PHP数学方程函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆