Get the Apache and PHP Version Info

If you are developing PHP code for a website you might sometimes want to check which version of Apache or PHP will be running the website. This is particularly true if you use some functionality that was included at a particular revision of the software or if you want to avoid security holes that were present in an older version. There are two simple ways to get this information using phpinfo() or the SERVER_SIGNATURE:

{code type=php}
<?php phpinfo(); ?>


{code type=php}

Both of these will return a lot of extra information to just the Apache and PHP versions. One way to reduce the amount of information is to split the array returned by $_SERVER and only keep the parts you are interested in. This approach is shown in the following example:

{code type=php}// Splits the output into an array
$ar = split(“[/ ]”,$_SERVER[‘SERVER_SOFTWARE’]);
// Loops through the array
for ($i=0;$i<(count($ar));$i++)
// Gets the Apache Version
case ‘APACHE’:
$Apache_Ver = $ar[$i];
// Gets the PHP Version
case ‘PHP’:
$PHP_Ver = $ar[$i];

As well as the Apache and PHP information obtained in the example, this approach can be used to obtain information about the software running on the server.


Leave a Reply

Your email address will not be published.

More Posts

How to use PHP Type Declarations

PHP has developed into a more strictly typed language in recent years. Type Declarations help with that and are a fairly new addition to PHP,


If you have come to JavaScript from a background in Java or C, then you will like the variation on the for loop. It is

Context Object Manipulation

One of the key concepts of JavaScript is the keyword this, which signifies the JavaScript context object. If you write an inner function, you can access

Polymorphic Functions

It is possible to define multiple functions with the same name in JavaScript, and the last one of those that you define will be the