In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "how to judge odd or even in php", so the editor summarizes the following contents, detailed contents, clear steps, and certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to judge odd or even in php" article.
In php, you can use the remainder operator "%" and the equality operator "= =" to determine whether a number is odd or even, just use the "%" operator to get the remainder after dividing the specified number by 2, and use the "=" operator to determine whether the remainder is 0; the syntax is "$num%2==0", if true is returned, it is even, and vice versa.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The essence of judging whether a number is odd or even is to judge whether the number can be divisible by 2:
If it is divisible by 2, it is even.
If it is not divisible by 2, it is odd.
So how to implement the divisible function in PHP?
In PHP, the remainder operator "%" can be used to determine whether to divide or not.
If a number is divided by 2 and there is no remainder (0), then it is divisible by 2, which is an even number.
If a number is divided by 2 and there is a remainder (not 0), then it is not divisible by 2, which is odd.
Well, at this point, you should know how to tell whether it is odd or even: using the "%" operator. Syntax:
$num%2==0
Here is an example to learn more about:
The above is about the content of this article on "how to judge whether it is odd or even in php". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.