The `rint()` function is a new addition in PHP 8.2 that rounds a floating-point number to the nearest integer value, using the current rounding mode. It's similar to `round()`, but it uses the rounding mode set by `float_round_mode` in the PHP configuration.PHP 8. PHP 8.1,PHP 8.2,PHP 8.3 and PHP 8.4.
Syntax<?phprint(float $num): float?>
Example Usage<?php// Rounding to nearest integerecho rint(3.4); // Output: 3echo rint(3.6); // Output: 4echo rint(-3.4); // Output: -3echo rint(-3.6); // Output: -4// Halfway cases (depends on rounding mode)echo rint(3.5); // Typically outputs 4 (rounds up)echo rint(4.5); // Typically outputs 4 (rounds to even)// With different rounding modesini_set('float_round_mode', PHP_ROUND_HALF_UP);echo rint(2.5); // Output: 3ini_set('float_round_mode', PHP_ROUND_HALF_DOWN);echo rint(2.5); // Output: 2ini_set('float_round_mode', PHP_ROUND_HALF_EVEN);echo rint(2.5); // Output: 2echo rint(3.5); // Output: 4?>Key Points1. `rint()` returns a float (not an integer) that represents the rounded value2. The rounding behavior for halfway cases depends on the current rounding mode3. Default rounding mode is typically `PHP_ROUND_HALF_UP` or `PHP_ROUND_HALF_EVEN`4. You can change the rounding mode using `ini_set('float_round_mode', mode)`The `rint()` function is particularly useful when you want to respect the system-wide rounding mode configuration.