我可以在变量中使用运算符吗
Can I use operator in variable
我可以在 php 中编写如下代码吗?
$operator = ">=90";
$val = 100;
if($val.$operator){
echo "Correct!";
}
查看eval() function. Though, I would say you should look into closures and even arrow functions。
$operator = fn($x) => $x >= 90;
$val = 100;
if($operator($val)){
echo "Correct!";
}
我可以在 php 中编写如下代码吗?
$operator = ">=90";
$val = 100;
if($val.$operator){
echo "Correct!";
}
查看eval() function. Though, I would say you should look into closures and even arrow functions。
$operator = fn($x) => $x >= 90;
$val = 100;
if($operator($val)){
echo "Correct!";
}