Calculate a sum in a string

前端 未结 5 891
我寻月下人不归
我寻月下人不归 2020-12-20 05:05

I have string like this: $string = \"a + b + c\";. Now I would like to calculate the string as sum.

For example:

$a = 10;
$b = 10;
$c =          


        
5条回答
  •  死守一世寂寞
    2020-12-20 05:16

    Your question may already have been answered here on StackOverflow:

    How to evaluate formula passed as string in PHP?

提交回复
热议问题