Forum Moderators: coopster

Message Too Old, No Replies

Get the version of PHP from script

         

Nutter

9:38 pm on May 7, 2006 (gmt 0)

10+ Year Member



How would I go about getting the version of PHP installed on the server from within a PHP script? I've got a couple functions that mimic functions found in PHP5 for people using previous versions, but I only want to define them if they're not using version 5.

Saikou

9:43 pm on May 7, 2006 (gmt 0)

10+ Year Member



You should try using php.net for simple functions..

<?php
// prints e.g. 'Current PHP version: 4.1.1'
echo 'Current PHP version: ' . phpversion();

// prints e.g. '2.0' or nothing if the extension isn't enabled
echo phpversion('tidy');
?>

Supports PHP 3, 4, & 5

You could also change it around a bit...

Also, if you're the only one going to see it, you could also use phpinfo();

e.g.

<?php

phpinfo();

?>