Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to judge the size of several numbers by php

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to judge the size of several numbers by php". In daily operation, I believe that many people have doubts about how to judge the size of several numbers by php. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "how to judge the size of several numbers by php". Next, please follow the editor to study!

Judgment method: 1, use the comparison operator "", "=", for example "$a > $b", if "$a" is greater than "$b" then return TRUE;2, use the comparison function strcmp (), syntax "strcmp (number 1, number 2)", if the return value is greater than 0, the number 1 is greater than the number 2, if the return value is 0, the two numbers are equal.

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Php judges the size of several numbers.

Method 1: use the comparison operators "", "="

Example name description $a

< $b小与如果 $a 的值小于 $b 的值,则返回 TRUE,否则返回 FALSE$a >

TRUE is returned if the value of $an is greater than that of $b, otherwise FALSE$a = $b is greater than or equal to the value of $b, TRUE is returned, otherwise FALSE is returned.

Example:

Method 2: use the comparison function strcmp ()

The strcmp () function makes a binary-safe comparison of two strings.

Strcmp (number 1, number 2)

Depending on the comparison result, the strcmp () function returns different values:

If the number 1 is less than the number 2, the value is returned

< 0; 如果 数1 大于 数2,则返回值 >

0

If the number 1 is equal to the number 2, 0 is returned.

Example:

At this point, the study on "how to judge the size of several numbers by php" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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: 274

*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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report