PHP errors - Notice: Undefined index in shorthand if/else -
i know notice: undefined index error lack of isset().
below statements doesn't errors or notices :
if (isset($_session['userid'])) { $userid = $_session['userid']; } but following statements, notice: undefined index :
$userid = $_session['userid'] ? isset($_session['userid']) : null; please tell me why when using shorthand if/else notice?
you doing wrong. should like:
$userid = isset($_session['userid']) ? $_session['userid'] : null; first check if variable set use value.
Comments
Post a Comment