I am calling a PHP script from bash and occasionally I will supply it 2 or sometimes 3 parameters like so
Bash script
 ip =  192.168.1.4
 name = machine2
 callScript=`/usr/bin/php check.php $ip $name`
 callScript2=`/usr/bin/php check.php $name`
As you can see, on one occasion I call the PHP script with two parameters, and on another with one parameter. The problem begins with the second, because PHP has argv[1] and argv[2] and then PHP complains stating PHP Notice:  Undefined offset: 2 because no second parameter was passed
Here is my PHP script
$placeholder = NULL;
if ($argv[2] === NULL) {
   //Do nothing
} else {
   $placeholder = $argv[2];
}
I am doing this so that if a second parameter is passed, store it in the placeholder, but if not don't do anything. The problem is PHP stops right on the second line of my code because $argv[2] does not exist as I only supply it one parameter on occasion.
 
    