开发者

want to create a Dayanamic formula creater in PHP [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I want to make a dayanamic formula creater in which user saves his formula in a varriable and this varriable will hav to show in other dropdown list.

When we select the formula name from the dropdown list there should be all the fields would be displayed which he had given in the formula nd after that just evaluate the string.

How 开发者_开发问答can I do this in PHP?

example- formula name= variable field (+ or any operator)variable field(+or any operator) this formula name would be shown in a other dropdown list nd user select formula from the dropdown list nd there two operator field which we given above should display....


Mohit,

why don't you use eval function? ( very danger function only use if code used in admin side or something like that)

here is simple example of dynamic execution of mathematical formula in PHP.

suppose you have variable $a=25 and $b=15 already bound and you want execute user saved formula [($a+$b)/2].

$a=25;
$b=15;
$formula = "($a+$b)/5";
echo eval($formula); // Result will be 20
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜