Method 1: Use $_MODULE['variable name']
if($_MODULE['var']) { // 这是表示已经输入了值 } else { // 这里表示未输入值 }
Method 2: Assign the value first, and then use empty to judge.
Note: Any uninitialized variable, a variable with a value of 0 or false or an empty string "" or null, an empty array, or an object without any attributes will be judged as empty==true
Note 1: Uninitialized variables can also be detected as "empty" by empty
Note 2: empty can only detect variables, not statements
$a = 0; $b = ''; $c = array(); if (empty($a)) echo '$a 为空' . ""; if (empty($b)) echo '$b 为空' . ""; if (empty($c)) echo '$c 为空' . ""; if (empty($d)) echo '$d 为空' . "";
Recommendation:phpserver
The above is the detailed content of PHP determines whether it is an empty string. For more information, please follow other related articles on the PHP Chinese website!