Check all php version installed mac

Here are some quick tips on how to check the PHP version on your computer or server.

There are several reasons why you want to check the version of PHP which is installed on your server. For example, you might want to install PHP-based software and to check if the software requirements match the PHP version installed on your server. Or you might be a developer who wants to use a feature which is only available in specific versions of PHP. 

There are a lot of different PHP versions, and they have some noticeable differences among them. With every new PHP version, new features are added and others are deprecated, so it’s always good to know the PHP version you’re using.

There are a few different ways to check the PHP version. Mainly, if you have SSH access to your server, you can use the command-line interface to check it. On the other hand, if you don’t have terminal access, I’ll show you how to check the PHP version using the phpinfo function.

Check the PHP Version by Using the Terminal

In this section, we’ll discuss how you could check the PHP version by using the command-line interface [CLI] in a terminal.

Check the PHP Version on Unix, Linux, and macOS

For *nix-based systems—Linux, Unix, and macOS—it just takes a single command to check the PHP version. Go ahead and run the following in your terminal.

php -v

You should see an output like the following:

PHP 7.2.24-0ubuntu0.18.04.3 [cli] [built: Feb 11 2020 15:55:52] [ NTS ]
Copyright [c] 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright [c] 1998-2018 Zend Technologies
    with Zend OPcache v7.2.24-0ubuntu0.18.04.3, Copyright [c] 1999-2018, by Zend Technologies

As you can see, this gives you comprehensive information about the PHP version which is installed on your server. In the above output, the 7.2.24 version of PHP is installed on the server.

Check the PHP Version on Windows

For Windows users, the same command is used to check the PHP version. But you might get an error if you don't set the PATH environment variable first. You can do that by running the set PATH command. Run the following commands, and make sure that you replace the {PATH_TO_PHP_DIRECTORY} placeholder with the directory path where you’ve installed PHP. For example, if you installed PHP in the C:\software\php directory, you need to run set PATH=%PATH%;C:\software\php.

set PATH=%PATH%;{PATH_TO_PHP_DIRECTORY}
php -v

If you don’t want to set the PATH environment variable, you could also go to the directory where you’ve installed PHP and run the php -v command from there.

cd C:\softwares\php
php -v

So that was a brief introduction to the CLI option to check the PHP version. In the next section, we’ll discuss how you could check your PHP version with the phpinfo function.

Check the PHP Version by Using the phpinfo Function

You can also use the phpinfo function, which prints detailed information about the PHP software on your server and its configuration.

This option is especially useful when you don’t have SSH access to the server where your site is hosted. If you want to use this option to check the PHP version on the remote server, all you need is the ability to upload a PHP file, for example with FTP or a web-based portal.

Create a file called php_version_check.php file with the following contents. 

Upload this file to the root directory of your site. Once you’ve done that, you should be able to access it at the //example.com/php_version_check.php URL [replacing example.com with your own domain name]. It should produce output like that shown in the following screenshot.

phpinfo Security Risks

As you can see, the PHP version is displayed right on the top of the page. Also, it displays a lot of other important configuration information as well. This information can be very useful if you are setting up or debugging a PHP installation. It can also be very useful for hackers, allowing them to pinpoint specific vulnerabilities in your system! 

That's why I strongly recommend you remove this file from the server once you’ve finished checking the PHP version.

Learn PHP With a Free Online Course

If you want to learn PHP, check out our free online course on PHP fundamentals!

In this course, you'll learn the fundamentals of PHP programming. You'll start with the basics, learning how PHP works and writing simple PHP loops and functions. Then you'll build up to coding classes for simple object-oriented programming [OOP]. Along the way, you'll learn all the most important skills for writing apps for the web: you'll get a chance to practice responding to GET and POST requests, parsing JSON, authenticating users, and using a MySQL database.

Did you find this post useful?

Software Engineer, FSPL, India

I'm a software engineer by profession, and I've done my engineering in computer science. It's been around 14 years I've been working in the field of website development and open-source technologies. Primarily, I work on PHP and MySQL-based projects and frameworks. Among them, I've worked on web frameworks like CodeIgnitor, Symfony, and Laravel. Apart from that, I've also had the chance to work on different CMS systems like Joomla, Drupal, and WordPress, and e-commerce systems like Magento, OpenCart, WooCommerce, and Drupal Commerce. I also like to attend community tech conferences, and as a part of that, I attended the 2016 Joomla World Conference held in Bangalore [India] and 2018 DrupalCon which was held in Mumbai [India]. Apart from this, I like to travel, explore new places, and listen to music!

Is PHP already installed on Mac?

PHP comes preinstalled on most macOS systems, so you usually don't need any manual installation. You may need to do extra configuration if you don't like some file settings' default values.

How do you check which PHP version is installed?

1. Type the following command, replacing [location] with the path to your PHP installation. 2. Typing php -v now shows the PHP version installed on your Windows system.

How do I install different versions of PHP on Mac?

Switching between multiple PHP versions on macOS.
Prerequisites. You'll need both Xcode Command Line Tools and Homebrew installed. ... .
Install Multiple PHP Versions. As of writing, only PHP 7.2, 7.3 and 7.4 are maintained and supported by Homebrew. ... .
Switching between PHP versions..

How do I remove old versions of PHP Mac?

Common Manual Ways to Uninstall PHP on Mac.
Click Finder and tap on the Applications category..
Select PHP and drag it to the Trash icon or you can also right-click on it and click Move to Trash..
Now, right-click on the Trash icon again and select Empty Trash..

Chủ Đề