$s = "text";
$exploded_s = explode('/', $s);
//$s2 = isset_or($exploded_s[1], "empty"); //This shows notice Undefined offset: 1
$s2 = isset($exploded_s[1]) ? $exploded_s[1] : "empty"; //This is ok
echo $s2;
function isset_or($var, $val){
return isset($var) ? $var : $val;
}
Both return "empty" but the first way also shows the notice. Why?