isset()为NULL返回任何内容

I have written this php code

//check if user has active plan and search keyword is not empty
    if (!empty($request['advertisername']) && ($userSubscriptionType == env('AMEMBER_STD_PLAN_CODE') || $userSubscriptionType == env('AMEMBER_PRE_PLAN_CODE'))) {
        $advertisername = 'LOWER(post_owner) like "%' . strtolower($request["advertisername"]) . '%"';
    } else {
        //if search keyword is null, means page is loaded for first time
        if (!isset($request['advertisername'])) {
            $advertisername = "true";
        } else {//if search keyword is not null, and user has not active plan
            $response->code = 400;
            $response->msg = "Permission issues";
            $response->data = "";
            return json_encode($response);
        }
    }

Here $request['advertisername']=null coming from fronend. So this condition will be true if (!isset($request['advertisername'])) {. But unfortunately it's always going to last else block.

If i save $request['advertisername'] in a variable like this. Then this condition if (!isset($advertiserName)) { becomes true.

//check if user has active plan and search keyword is not empty
if (!empty($request['advertisername']) && ($userSubscriptionType == env('AMEMBER_STD_PLAN_CODE') || $userSubscriptionType == env('AMEMBER_PRE_PLAN_CODE'))) {
    $advertisername = 'LOWER(post_owner) like "%' . strtolower($request["advertisername"]) . '%"';
} else {
    //if search keyword is null, means page is loaded for first time
    $advertiserName=$request['advertisername'];
    if (!isset($advertiserName)) {
        $advertisername = "true";
    } else {//if search keyword is not null, and user has not active plan
        $response->code = 400;
        $response->msg = "Permission issues";
        $response->data = "";
        return json_encode($response);
    }
}

I checked the condition via var_dump(). Anyone can explain why it is happening?

you can use is_null() instead of !isset().

You can use array_key_exists() instead:

if (!array_key_exists('advertisername', $request)) {

Please note the PHP manual for isset() says:

isset — Determine if a variable is set and is not NULL

A good way would be to check if the variable is not empty as it checks both isset and null

eg if(!empty($your_variable) {    /** your code here **/   }