Integers do not have priority over real numbers, but they are destined for a largely "non-digital" purpose. An exact number with a specific number of digits and/or in a specific range of values makes sense for generating CSS rules, can be used as an array key or a unique record code for a database table row. The integer can be part of a unique code, a password, or a checksum when transmitting data. An integer is far from mathematics and numerical methods, it is often an element of a given or its code.
Meaning of the intval() function
The PHP intval() function is used to convert "variable to integer", has two parameters and double meaning.
The second parameter is the base of the required number system. The decimal system is used by default. If you do not specify the second parameter, then the number that starts with the character "0" is considered octal, and from the characters"0x" - hexadecimal.
The second parameter matters if the first parameter is a character string.
The last two examples (very large values) show that the result is inappropriate. Essentially, the bit depth of the machine (operating system) matters here. In practice, converting such numbers does not make much sense.
The PHP intval function logic is to convert a string or number to an integer for practical use. For example, create a CSS rule that only uses integers. Convert a real number to an integer by simply removing only the integer part.
Using the intval() function
The intval() function in PHP is not the only one for the purpose of getting an integer. You can use round(), ceil() and floor(). These functions operate with common rounding logic.
The PHP intval() function is devoid of any logic and acts on the principle of getting an integer. If required, then according to the desired base of the desired number system.
The above examples of PHP intval() show that its main area of application is the logic of the algorithm, and not the logic of calculations.
This function is an ideal tool for generating data for correctly displaying an HTML page (using CSS rules and HTML tag attributes in parameters) and creating array keys, database table rows, action numbering, event counting.