PHP filter_input: how to return NULL when it is empty from the input

Hi,

How can I return NULL with filter_input when the input is empty?

$title = filter_input(INPUT_POST, 'title');
    var_dump($title);

it returns,

string '' (length=0)

but I want,

null

Thanks.

You can only get NULL as the return value if the $variable is not set or fails to be filtered.

got it thank you. I think I have write a function or a couple of extra lines to return null for my case. thanks. :slight_smile: