Variable Operators in PHP

前端 未结 5 850
青春惊慌失措
青春惊慌失措 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 02:50

    Quick answer is eval(). However, in this precise example I would just hard-code the possible operations:

    orderField] + 1;
                break;
        }
        echo $result;
    }
    
    ?>
    

提交回复
热议问题