php - Please can anyone help explain to me the meaning of the following codes? -


please me understand following codes:

<?php session_start(); if(!isset($_session['staffid'])){     $_session['staffid']=""; } ?> 

does mean if there not set of staffid, set null?

it's checking see if key 'staffid' exists in $_session array.

for example, if have array:

$person = array( 'name' => 'george', 'age' => 22); 

then isset($person['name']) return true isset($person['height']) return false.

so code sample sets $_session['staffid'] '' (an empty string), if key has not been set yet $_session.

edit: it's worth noting if didn't know $_session variable special meaning in php, see docs.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -