Variable Operators in PHP

前端 未结 5 835
青春惊慌失措
青春惊慌失措 2020-12-07 02:15

Given this example, how would I return the result of the equation rather than the equation itself as a string?

$operator = \'+\';
foreach($resultSet as $item         


        
5条回答
  •  太阳男子
    2020-12-07 03:08

    You can use eval(), but it's generally a bad idea, since it's a major potential security hole (be careful you're not allowing visitors to run arbitrary code!).

    It can also result in hard to maintain code.

提交回复
热议问题