Since PHP is a dynamic language what's the best way of checking to see if a provided field is empty?
I want to ensure that:
- null is considered an empty string
- a white space only string is considered empty
- that "0" is not considered empty
This is what I've got so far:
$question = trim($_POST['question']);
if ("" === "$question") {
// Handle error here
}
There must be a simpler way of doing this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…