We use intval to determine whether the user input is a number. this can be automatically converted to a number. if it is 0, the returned value is false, in php, to determine whether the user input is a numeric string or a numeric string, we will use is_numeric and in... we use intval to determine whether the user input is a number. this can be automatically converted to a number. if it is 0, the returned value is false, in php, we will use the is_numeric and intval functions to determine whether the user input is a numeric string or a numeric string. the instance code is as follows:
$ Num = 1; $ num1 = '1'; $ str = 'abc'; if (is_numeric ($ num) {echo $ num. 'is a numeric type';} // 1 is a numeric if (is_numeric ($ num1) {echo $ num1. 'is a numeric type';} else {echo $ num1.' not a numeric type ';}
// 1 is digital
The second example is whether it is a numeric type. it depends on whether php is a language of that type. The key is that php is a weak language type, so it will automatically convert the numeric type into numbers, the instance code is as follows:
If (intval ($ str) {echo $ str. 'is a number';} else {echo $ str. 'Not a digit';} // acd is not a number if (intval ($ num1) {echo $ num1. 'is a digit';} else {echo $ num1. 'not a digit ';} // 1 is a number
Tutorial address:
Reprinted! But please include the article address ^