Using a variable as an operator

后端 未结 11 1446
滥情空心
滥情空心 2020-12-06 09:31

So I have something like the following:

$a = 3;
$b = 4;
$c = 5;
$d = 6;

and I run a comparison like

if($a>$b || $c>$d         


        
11条回答
  •  离开以前
    2020-12-06 09:58

    You could use eval, but that you could easily end up exposing your site to all sorts of code injection attacks if you're not very careful.

    A safer solution would be to match the proposed operator against a predefined white list and then call a corresponding bit if code with the operator hard - coded.

    C.

提交回复
热议问题