Check Apache version by PHP

Beside use command to check the version, you can use the php script to check the php version. Why that so? So application do need to verify by php first before allow you to install the apps.

<?php

$ar = split("[/ ]",$_SERVER['SERVER_SOFTWARE']);
for ($i=0;$i<(count($ar));$i++)
{
switch(strtoupper($ar[$i]))
{
case 'APACHE':
$i++;
$Apache_Version = $ar[$i];
break;
case 'PHP':
$i++;
$PHP_Version = $ar[$i];
break;
case 'MOD_SSL':
$i++;
$MOD_SSL_Version = $ar[$i];
break;
case 'OPENSSL':
$i++;
$OPENSSL_Version = $ar[$i];
break;
}
}

Echo "Apache Version: $Apache_Version<br>\n";
Echo "PHP Version: $PHP_Version<br>\n";
Echo "mod_ssl Version: $MOD_SSL_Version<br>\n";
Echo "OpenSSL Version: $OPENSSL_Version<br>\n";

?>

Leave a Reply

Your email address will not be published. Required fields are marked *