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:
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?
Function for basic field validation (present and neither empty nor only white space
function IsNullOrEmptyString(string|null $str){
return $str === null || trim($str) === '';
}