-2

I've been getting this error. Any fix??

PHP Notice: Undefined offset: 1 in line 402

if ($argv[1] == '--cover')
{
    $Modules = new Modules;
    $Modules->cover();
    die();
}

The line is if ($argv[1] == '--cover')

Nic3500
  • 8,144
  • 10
  • 29
  • 40

2 Answers2

1

An offset is undefined if it doesn't exist in the array. Try this:

if(isset($argv[1]) && $argv[1] == '--cover'){
$Modules = new Modules;
$Modules->cover();
die();
RGe
  • 1,181
  • 1
  • 10
  • 19
0

This error means that the $argv[1] is undefined or null. Make sure this variable is properly assign or have a value before making a condition.

using print_r($argv); before making a condition will help you if the variable have a value or not.

Ed Ward
  • 26
  • 3