There are two ways to express range in PHP: Between operator: start <= value <= end (inclusive range) Range operator: start ... end (exclusive range, only applicable to PHP 5.3 and later, and only for numeric types)
Methods for representing ranges in PHP
PHP The range of a value can be expressed in two ways:
1. Use the between operator
The syntax of the between operator (inclusive range) is:
start <= value <= end
For example:
if ($age >= 18 && $age <= 65) { // 18 岁到 65 岁之间的成年人 }
2. Use the range operator
The syntax of the range operator (exclusive range) is:
start ... end
For example:
if ($age >= 18 && $age < 65) { // 不包括 65 岁,18 岁到 64 岁之间的成年人 }
Note:
The above is the detailed content of How to express a range of values in php. For more information, please follow other related articles on the PHP Chinese website!