Process mathematical equations in php

后端 未结 8 1919
陌清茗
陌清茗 2020-11-30 14:14

A user is allowed to enter any mathematical equation they like (with one variable):

x + 5

1 - x/2

(x/3) * (56/13)

8条回答
  •  无人及你
    2020-11-30 14:33

    Using eval function is very dangerous when you can't control the string argument.

    Try Matex for safe mathematical formulas calculation. It supports also variables and custom functions.

提交回复
热议问题