问题描述:

This question already has an answer here:

  • PHP: “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset”

    19 answers

网友答案:

You should first check if your element exists in your array:

if (array_key_exists('aktifko',$_COOKIE) AND $_COOKIE['aktifko'] != 'XXX')

With your current code, you are checking the value of this element in the cookie array. But if it's the first time for the user, this element won't exist in the array. So you have to check if the key already exists before checking its value.

相关阅读:
Top