I try to run a PHP script from command line to check if a specific webserver is running, but it doesn't work.
This one works:
$to = 'mail@address.com';
$subject = 'LSWS Check';
$message = 'Apache is Running';
$headers = 'From: root' . "\r\n" . 'Reply-To: mail@address.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
$serverSoftware = $_SERVER['SERVER_SOFTWARE'];
$isWebserver = 'Apache';
mail($to, $subject, $message, $headers);
This one doesn't work:
$to = 'mail@address.com';
$subject = 'LSWS Check';
$message = 'Apache is Running';
$headers = 'From: root' . "\r\n" . 'Reply-To: mail@address.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
$serverSoftware = $_SERVER['SERVER_SOFTWARE'];
$isWebserver = 'Apache';
if (strpos($_SERVER[$serverSoftware], $isWebserver) !== false) {
mail($to, $subject, $message, $headers);
}
strpos($_SERVER[$serverSoftware] doesn't work, but why?