Because php is a weakly typed language, many programmers who develop php for the first time are not very concerned about or familiar with the data types of php, but they often need to judge the data types in some common business implementations!
Share a problem encountered in the process of business realization some time ago!
Like this connecting :www.davup.com/index.php? . add = 1000. 1
In the past, normal logic would directly use get['add'] to represent it.
Is_number () determines whether it is a numeric value.
Is is_float () a decimal?
To judge. It turns out that this treatment is misplaced! Because whether it is Post data or Get data, the data type of the value obtained in php is string!
Therefore, the above two functions can not be used normally, and can only be handled by string functions! The easiest way is to use strstr(get['add'],'.'); Judge whether there is a decimal point, if there is a decimal point, return true, if not, return false!