Best way to get PHP version here we will use PHP_VERSION constant variable to get a current PHP version of your server


Method 1:

Use the phpversion() get current Version of PHP

<?php
$version = phpversion();
print $version;
?>

Output:

7.3.25

Method 2:

Use the PHP_VERSION constant variable to get current Version of PHP

<?php
  echo PHP_VERSION;
?>

Output:

7.3.25