>!= PHP运算符,不等于或大于怎么写?

发布于 2024-09-08 20:09:55 字数 58 浏览 5 评论 0原文

如何在 PHP 中编写不大于或等于?

>!= 吗?

How can I write not greater-than-or-equal-to in PHP?

Is it >!= ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

晚雾 2024-09-15 20:09:55

不大于或等于 x小于 x 不一样吗?

Isn't not greater than or equal to x the same as less than x ?

别念他 2024-09-15 20:09:55

哦,有趣。按照复杂性递增的顺序:

  1. <
  2. (a - b > 0)
  3. !(a >= b)
  4. = 0)
  5. !(a - b <= 0) !((a > b) || (a==b)) !(a - b <= 0) !((a > b) || (a==b))
  6. !(a - b < 0) && !(a - b == 0)
  7. !((a - b < 0) || (a - b == 0)) && !(!(a < b))
  8. !(a - b < ((a * (1/a)-1) * (b * (1/b)-1))) && !(a - b == (a * (1/a)-1) * (b * (1/b)-1)))

就我个人而言,我会为那些真正惹恼我的人保留#8。 ;)

Oh, fun. In increasing order of complexity:

  1. <
  2. (a - b > 0)
  3. !(a >= b)
  4. !(a - b <= 0)
  5. !((a > b) || (a==b))
  6. !(a - b < 0) && !(a - b == 0)
  7. !((a - b < 0) || (a - b == 0)) && !(!(a < b))
  8. !(a - b < ((a * (1/a)-1) * (b * (1/b)-1))) && !(a - b == (a * (1/a)-1) * (b * (1/b)-1)))

Personally, I would reserve #8 for someone who really annoyed me. ;)

如痴如狂 2024-09-15 20:09:55

最好的写法是

$x = 4;
$y = 6;

if($x < $y) echo "True";

// True

$x = 4;
$y = 6;

if(!($x >= $y)) echo "True";

// True

The best way to write this is

$x = 4;
$y = 6;

if($x < $y) echo "True";

// True

$x = 4;
$y = 6;

if(!($x >= $y)) echo "True";

// True
爱给你人给你 2024-09-15 20:09:55

“不大于或等于”相当于“严格小于”,即<

如果你真的想说“不大于或等于”,你可以直接写!(a >= b)

"not greater than or equal to" is equivalent to "strictly less than" which you write as <.

If you really wanted to say "not greater than or equal to" you could just write !(a >= b).

不念旧人 2024-09-15 20:09:55
<

(小于等于不大于或等于)

<

(less than is the same as not greater than or equal to)

云雾 2024-09-15 20:09:55

从技术上讲,您提出了两个不同的问题 - 如何编写A不大于B或A等于BA不等于B或A大于B

语句A不大于B或A等于B意味着:

!(A > B) || A == B

这是一个同义反复:

A <= B

并且A不等于B或A大于B意味着:

A != B || A > B

这是一个同义反复:

A >= B

A A <的其他答案B 代表语句A 不大于也不等于B

Technically, you have asked two different questions - how to write A not greater than B or A equal to B and A not equal to B or A greater than B.

The statement A not greater than B or A equal to B implies:

!(A > B) || A == B

which is a tautology for:

A <= B

And A not equal to B or A greater than B implies:

A != B || A > B

which is a tautology for:

A >= B

The other answers of A < B are representative of the statement A not greater than nor A equal to B.

冰雪梦之恋 2024-09-15 20:09:55

只需使用 <

simply use < ?

雾里花 2024-09-15 20:09:55

为了向不相信的人证明小于与不大于或等于不同:

<?
$i = acos(4);
print $i."\n";
print is_nan($i)."\n";
if (4>=$i) {
    print "ge\n";
} else {
    print "nge\n";
}
if (4<$i) {
    print "lt\n";
} else {
    print "nlt\n";
}
?>

它在我的系统上输出:

$ php5 nan.php 
NAN
1
ge
lt

To prove the disbelievers that less than is different than not greater or equal:

<?
$i = acos(4);
print $i."\n";
print is_nan($i)."\n";
if (4>=$i) {
    print "ge\n";
} else {
    print "nge\n";
}
if (4<$i) {
    print "lt\n";
} else {
    print "nlt\n";
}
?>

It outputs this on my system:

$ php5 nan.php 
NAN
1
ge
lt
司马昭之心 2024-09-15 20:09:55

a 不大于或等于 b 相当于 b b b a一个

a not greater or equal to b is equivalent to b < a

多彩岁月 2024-09-15 20:09:55

看一下这个页面: http://www.php.net /manual/en/language.operators.logic.php

它显示了有关运算符的有趣的事情以及如何使用它们...我突出显示了这个特定的逻辑运算符页面,因为当您使用这些运算符时,这些运算符尤其具有不同的行为使用它们的相似词,例如“||”和“或”。

值得一看=)

Take a look at this page: http://www.php.net/manual/en/language.operators.logical.php

It shows interesting things about operators and how to use them... I've highlighted this specific logical operators page because these, in particular, has different behaviors when you use their similars, like "||" and "or".

It's worth to take a look =)

自由范儿 2024-09-15 20:09:55

按照您所说的方式去做

!>或<>

Doing it the way you word it

!> or <>

残龙傲雪 2024-09-15 20:09:55

一些简单的例子:

<?php 

#not lower than 5 AND not greater than 12 

if(!($nr<5)&&!($nr>12)){ }

?>

Some simple example :

<?php 

#not lower than 5 AND not greater than 12 

if(!($nr<5)&&!($nr>12)){ }

?>
背叛残局 2024-09-15 20:09:55

假设您想要测试 A 不等于或大于 B;

假设:

<前><代码>A = 10;

<前><代码>B = 20;

对于正常比较,代码将如下所示:

if(A >= B)
{
   return "A and B are equal";
}
else {
   return "A and B are not equal";
}

如果使用给定值执行上面的代码,那么我们期望语句 A 和 B 不等于,因为 10 不大于或等于20.

现在要测试 A >= B 的反转或否定版本,我们只需在表达式中添加 NOT 符号 (!) 即可实现反转。

if(!(A >= B))
{
   return "A and B are not equal";
}
else {
   return "A and be are equal";
}

运行上述代码的预期响应是返回语句 A 和 B 不相等

Given that you want to test that A is not equal or greater than B;

Assuming that :

A = 10;
B = 20;

For normal comparison the code would look something like this :

if(A >= B)
{
   return "A and B are equal";
}
else {
   return "A and B are not equal";
}

If the code above was executed with the given values, then we would expect that the statement A and B are not equal as 10 is not greater or equal to 20.

Now to test the reverse or the negated version of A >= B we would simply achieve it by adding the NOT symbol (!) in our expression to reverse it.

if(!(A >= B))
{
   return "A and B are not equal";
}
else {
   return "A and be are equal";
}

The expected response buy running the code above is that statement A and B are not equal will be returned.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文