Here are some quick tips on how to kiểm tra the PHP version on your computer or server.Bạn đã xem: Installation on windows systems
There are several reasons why you want to check the version of PHP which is installed on your server. For example, you might want khổng lồ install PHP-based software & 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, & they have some noticeable differences among them. With every new PHP version, new features are added & others are deprecated, so it’s always good khổng lồ know the PHP version you’re using.
Bạn đang xem: Hướng dẫn cách kiểm tra phiên bản php
There are a few different ways to kiểm tra the PHP version. Mainly, if you have SSH access to lớn your server, you can use the command-line interface to kiểm tra it. On the other hand, if you don’t have terminal access, I’ll show you how to kiểm tra the PHP version using the phpinfo function.
Check the PHP Version by Using the Terminal
In this section, we’ll discuss how you could kiểm tra 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 -vYou should see an output lượt thích the following:
Check the PHP Version on Windows
set PATH=%PATH%;PATH_TO_PHP_DIRECTORYphp -vIf you don’t want to lớn set the PATH environment variable, you could also go to the directory where you’ve installed PHP & run the php -v command from there.
cd C:softwaresphpphp -vSo that was a brief introduction lớn 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 và its configuration.
This option is especially useful when you don’t have SSH access khổng lồ the server where your site is hosted. If you want lớn 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 tệp tin with the following contents.
Upload this file to lớn the root directory of your site. Once you’ve done that, you should be able to lớn access it at the http://example.com/php_version_check.php URL (replacing example.com with your own domain name 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 khổng lồ pinpoint specific vulnerabilities in your system!
That"s why I strongly recommend you remove this tệp tin from the hệ thống once you’ve finished checking the PHP version.
Learn PHP With a free Online Course
If you want to lớn learn PHP, kiểm tra out our không tính tiền online course on PHP fundamentals!