I have this code and the issue is it’s giving output from $2,147,483,647 where as I have set 3000000000 that is $3,000,000,000
And I want out from what we set there in form but if we choose higher $2,147,483,647 it start from $2,147,483,647
Here are my codes.
$v = isset($_GET['v']) ? (int) $_GET['v'] : 3000000000;
First time it gives correct. But when we change the value in the form it gives the wrong output.
You’re encountering a case of integer overflow, as the maximum value of PHP’s integer is 2^31-1 which evaluates to 2147483647. PHP handles integer overflow by just limiting values to the edge of the bounds they go beyond.
To solve this, you can use a float, which has a much larger range of values. There are several ways to declare a number as a float, such as using E notation or via casting, both as shown below.