To check if the variable if really null you can use the identity operator:
$user_id === NULL // FALSE == NULL is true, FALSE === NULL is false
is_null($user_id)
To check if the variable is not set use this:
!isset($user_id)
If the variable is not empty, an empty string, zero:
empty($user_id)
If you want to test whether a variable is not an empty string,! will also be sufficient:
!$user_id
I hope this helps you.