Preforming math stored in variables

前端 未结 4 1522
借酒劲吻你
借酒劲吻你 2021-01-21 11:03

I have 3 variables like this: $first = 2; $second = 5; $operation = \'*\';

how can I programaticly assign the solution to this math problem to the $answer variable? I ha

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-21 11:09

    eval() should work perfectly fine for something like this. Remember that eval() returns NULL though, unless you tell it to return something.

    
    

提交回复
热议问题