How to check the PHP version

Question

Answers ( 1 )

    0
    2024-01-11T18:05:22+00:00

    To check the version of PHP installed on your system, there are several methods you can use:

    Method 1: Using the Command Line

    1. For Windows:

      • Open the Command Prompt (cmd).
      • Type php -v and press Enter. This command should return the PHP version installed.
    2. For Linux or macOS:

      • Open a terminal window.
      • Type php -v and press Enter. This should display the PHP version.

    Method 2: Using a PHP Script

    If you have access to a server where PHP is installed and can run PHP scripts, you can create a small PHP script to display the version:

    1. Create a PHP file, e.g., version.php.

    2. Write the following code in it:

      <?php
      echo 'PHP version: ' . phpversion();
      ?>
      
    3. Run this script on your web server, and it will display the PHP version.

    Method 3: Using phpinfo()

    Another option is to use the phpinfo() function, which provides a comprehensive overview of the PHP configuration and version:

    1. Create a PHP file, e.g., phpinfo.php.

    2. Write the following code:

      <?php
      phpinfo();
      ?>
      
    3. When you run this script on a web server, it will display a lot of information about PHP, including the version.

    Method 4: Checking in Web Hosting Control Panel

    If you're using a web hosting service, you can usually find the PHP version in the control panel (like cPanel, Plesk, etc.). Look for sections named "Software", "PHP", or similar.

    Each of these methods will help you determine the version of PHP installed on your system or server.

Leave an answer