As Gregor pointed out you could check for the existence of the array key, but this would negate one of the key advantages of PHP in that you can use variables without initalisation which in controlled conditions can be exceptionally useful.
The warning is there to inform you that you are using an uninitalised variable, which can be a security threat. If you are know where the data in $myvar comes from, or have a non public enviroment, you can simply turn of notices altogether. You can do this in your php.ini file or my adding the following line to the top of your code:
- Code: Select all
ini_set('error_reporting', 'E_ALL & ~E_NOTICE');