What is the main purpose for the maximum limit for number in php and mysql?
Does this means that we can/cannot process or store numbers that is larger than the limit?
I echo PHP_INT_MAX
and it shows 2147483647
.
I multiply by 1000000000000000000000
and get answers like 2.147483647E+30
which i think is already over the limit?
Please advise.
Many thanks for guidance.
This question arise when I'm thinking about validating the user form input. I want to make sure that the user input is according to our defined number format and not something else.
Then i do some online search for best practices and come to aware of this "limits" but do not know how to handle it correctly when using PHP & MYSQL. Pls advise:
Step 1: trim and convert user form input "string number" to number.
Step 2: validate the number is in positive integer format.
Step 3: validate the number does not exceed my "max limit".
Since php limit (2,147,483,647) is smaller than mysql limit (18,446,744,073,709,500,000)? i'll take php as my max limit.
Step 4: perform some calculations...
Step 5: validate my result does not exceed my max limit.
Step 6: store the result in mysql.