Snippet

The PHP version is stored in the PHP_VERSION variable and is available to the script at runtime. This with the version_compare function we can evaluate and compare and do the required action as shown below

  1. // _Checks PHP Version
  2. function checksPHPVersion() {
  3.  
  4.       //check if this is less than 5.2.5
  5.     $check_525 = (version_compare(PHP_VERSION,'5.2.5') >= 0)?1 : 0;
  6.  
  7.     //check if this is greater than 5.3.0
  8.     $check_php_530 = (version_compare(PHP_VERSION,'5.3.0') >= 0)?1 : 0;
  9.  
  10.     // perform the desired operation
  11. }

<!>