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

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -