PHP: Notice Undefined index even using isset

吃可爱长大的小学妹 提交于 2021-01-29 09:28:21

问题


i'm getting this even using 'isset':

Notice: Undefined index

it's giving the error at:

returnifisset($_COOKIE["miceusername"], ' value="', '"');

even though i am checking if the cookie isset or not. The function is:

function returnifisset($variable, $first = '', $last = ''){
    if(isset($variable) and !empty($variable)){ return $first.$variable.$last; }
}

how i should modify this function to make it work and not give that error!


回答1:


You are actually accessing the variable by passing it with your function, before the isset is ever called. You can't solve this problem.




回答2:


You use different function names printifisset and returnifisset. Also you can use only !empty() statement



来源:https://stackoverflow.com/questions/7096914/php-notice-undefined-index-even-using-isset

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!