PHP错误 - 注意:如果/ else,则以简写形式定义未定义的索引

I know Notice: Undefined index error is about lack of isset().

Below statements doesn't get any errors or notices :

if (isset($_SESSION['userid'])) {
    $userid = $_SESSION['userid'];  
}

But following statements, get Notice: Undefined index :

$userid = $_SESSION['userid'] ? isset($_SESSION['userid']) : NULL;

Please tell me why when using shorthand if/else it get notice?

You are doing it wrong. It should be something like:

$userid = isset($_SESSION['userid']) ? $_SESSION['userid'] : NULL;

First check if the variable is set then use its value.

try putting it the right way round

$userid = isset($_SESSION['userid']) ? $_SESSION['userid']  : NULL;