For example, when I need to check some particular values, I create a " method ", similar to this:
public function verificaString($campo)
{
if (isset($_POST[$campo]) && (!empty($_POST[$campo]) && (is_string($_POST[$campo])))):
(string)$var = filter_var(trim($_POST[$campo]), FILTER_SANITIZE_STRING);
return $var;
else:
$var = 'Indisponível';
return $var;
endif;
}
Now thinking about this part more specifically:
if (isset($_POST[$campo]) && (!empty($_POST[$campo])
Is there a way to simplify this process?
Every time I need to check if a variable is set and it has a value other than null, do I have to do just that? Can not simplify this procedure?