find php version in php

To find the PHP version using the command line, follow these steps:

  1. Open your terminal or command prompt.
  2. Type the following command:
main.php
php -v
7 chars
2 lines
  1. Press Enter.

This command will display your PHP version on the command line. For example:

main.php
PHP 7.4.14 (cli) (built: Jan  7 2021 16:27:33) ( NTS )
55 chars
2 lines

Alternatively, you can create a PHP file with the following code to display the version on a web page:

main.php
<?php
  echo phpversion();
?>
30 chars
4 lines

When you navigate to this PHP file in a web browser, it will display the PHP version.

related categories

gistlibby LogSnag