Using a variable as an operator

后端 未结 11 1475
滥情空心
滥情空心 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:44

    It's not possible, but you could use a function instead. Of course, you'd have to define them yourself. This would be fairly simple using PHP 5.3's closures:

    $or = function($x, $y)
    {
        return $x || $y;
    };
    
    if ($or($a > $b, $c > $d))
    {
        echo 'yes';
    };
    

提交回复
热议问题