PHP Introduction | Functions | phpversion - Check the PHP Version

phpversion lets you check the PHP version. It can be used only with PHP 4 or later.

Syntax

phpversion()

Example

Create a file with any suitable name and write the following code.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>phpversion</title>
  </head>
  <body>
    <?php
      echo '<p>PHP current version is ' . phpversion() . '</p>';
    ?>
  </body>
</html>

It returns the PHP version as a string.