PHP:即使使用isset,也请注意未定义的索引 [英] PHP: Notice Undefined index even using isset

查看:81
本文介绍了PHP:即使使用isset,也请注意未定义的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使使用'isset',我也能做到这一点:

i'm getting this even using 'isset':

Notice: Undefined index

它在以下位置给出错误:

it's giving the error at:

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

即使我正在检查cookie是否已设置.功能是:

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!

推荐答案

您实际上是在调用isset之前通过将其与函数一起传递来访问变量的.您无法解决这个问题.

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

这篇关于PHP:即使使用isset,也请注意未定义的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆