Introduction
There are lots of different features in PHP that exist only in certain versions of PHP. For example, Object Oriented Programming (or OOP for short) was revamped in version 5, even though it has existed since PHP version 3. You can read more about PHP 5's object oriented features in Jordan's tutorial, http://forum.codecal...-php-5-oop.html.
The strange thing is, in quite a few hosting packages, companies don't actually disclose much data about the PHP installation. For example, in my 1&1 package I had no idea which version of PHP I had installed, as the signup page simply said "PHP 4 & 5".
Getting your PHP Version
Thank goodness PHP has addressed this problem. There is a function called phpinfo(), which tells you your PHP compilation options and extensions, the PHP version, server information and environment (if compiled as a module), the PHP environment, OS version information, paths, master and local values of configuration options, HTTP headers, and, of course, the all-important PHP License. It is incredibly simple to use.
1. Create a blank page and call it info.php. Open it in any editor of your choice and type the following code:
<?php //Echo the information page //to the browser. phpinfo(); ?>
And that's it! Note that phpinfo() can return a boolean value relating to the success or failure of the operation. Load the page up under your local server (or online server if you're using one) and you should see a page containing all the information you need.

Note, however, that you can also use phpinfo() with a single parameter, $with, as well. For more info on these bit-packed constants, see PHP: phpinfo - Manual for more details.
Just the PHP Version, please
If you want, you can just retrieve the PHP Version on its own, without the other stuff. To do this, just use the built-in phpversion() function.
<?php echo 'I am using PHP Version ' . phpversion(); ?>
Again, phpversion() can be used with a single parameter, this time a string argument denoting the name of the extension to the return the version for. Visit PHP: phpversion - Manual for details.
Xav
+rep if useful; leave any comments/queries below!
Edited by Xav, 23 August 2008 - 11:42 AM.


Sign In
Create Account


Back to top









