Проверка установки php windows

How To Check PHP Version And PHP Install Path On Linux And Windows

After you install PHP or LAMP on a Linux server ( or XAMP on a Windows Server ), if you want to run command php in a terminal to execute a .php script file, you should first find the PHP install path and add the php executable file path in system environment variable PATH‘s value.

But if there are multiple PHP version installed on the server, you should find the PHP version and related PHP install path which you need, and then you can run it accordingly. For example, you can invoke your required PHP version executable file on the Linux Cron job.

This article will tell you how to check current PHP version and PHP install path in both Linux and Windows. It will also tell you how to change current PHP version to another one by edit the system environment variable PATH‘s value.

1. Check PHP Install Path On Linux.

The whereis command returns the executable file path. From below example, we can see the PHP executable file path is /usr/bin/php , and it is linked to /www/server/php/73/bin/php file ( this is the real PHP executable file ).

$ whereis php php: /usr/bin/php $ $ ls -l /usr/bin/php lrwxrwxrwx. 1 root root 26 Dec 21 09:08 /usr/bin/php -> /www/server/php/73/bin/php

If whereis command returns multiple PHP install path, then you can run which command to get current PHP executable file path.

$ whereis php php: /usr/bin/php /usr/local/bin/php /usr/local/lib/php.ini $ $ which php /usr/local/bin/php

2. Check PHP Install Path On Windows.

It is very easy for you to check PHP install path on Windows, because install PHP on Windows is just download the PHP zip file and unzip it to a local folder, then you can run it in a dos window like below. In below example, the php install path is C:\xampp\php\.

C:\WorkSpace>C:\xampp\php\php -v PHP 8.0.0 (cli) (built: Nov 24 2020 22:02:57) ( ZTS Visual C++ 2019 x64 ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies

If you want to run above example just by input command php -v, then you need to add the PHP install path ( C:\xampp\php\ ) in Windows system environment variable PATH‘s value. You can read article How To Set Windows Environment Variables.

# First make sure php install path has been added in windows environment variable PATH's value. C:\WorkSpace>echo %PATH% . ;C:\xampp\php # Now you can run command php in command console. C:\WorkSpace>php -v PHP 8.0.0 (cli) (built: Nov 24 2020 22:02:57) ( ZTS Visual C++ 2019 x64 ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies

3. Check Current PHP Version.

Run php -v command in a terminal to get the current executed PHP version.

# php -v PHP 7.9.9. (cli) (built: Dec 21 2020 09:06:30) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.25, Copyright (c) 1998-2018 Zend Technologies

3. Use phpinfo() Function To Get PHP Version & PHP Install Path.

  1. The phpinfo() function can return a lot of useful information ( includes PHP Version and Install Path ) about currently used PHP.
  2. We can write a .php script file and contain the phpinfo() function in this file. Then we can execute it both in command-line or from HTTP web server.
  3. Open a terminal, run command vi test.php to create a .php script file.
  4. Press esc , i key to enter insert mode.
  5. Copy below source code into the test.php file.
$ php ./test.php phpinfo() PHP Version => 7.3.11 . .

Источник

Как проверить версию PHP

wikiHow работает по принципу вики, а это значит, что многие наши статьи написаны несколькими авторами. При создании этой статьи над ее редактированием и улучшением работали, в том числе анонимно, 13 человек(а).

Количество просмотров этой статьи: 28 346.

Если на веб-сайт нужно добавить новые функции или найти ошибку, узнайте версию PHP вашего сервера. Для этого запустите простой PHP-файл на своем веб-сервере. Также можно выяснить версию PHP на компьютере — это можно сделать с помощью командной строки или терминала.

Веб-сервер

Изображение с названием 2232402 1 1

Откройте текстовый редактор или редактор кода. Воспользуйтесь Notepad++, Блокнотом или TextEdit. Не пользуйтесь мощными текстовыми редакторами, такими как Microsoft Word.

Изображение с названием 2232402 2 1

Введите следующий код. Этот небольшой код отобразит версию PHP, если запустить его на веб-сервере. [1] X Источник информации

 echo 'Current PHP version: ' . phpversion(); ?> 

Изображение с названием 2232402 3 1

Сохраните файл в формате PHP. Нажмите «Файл» > «Сохранить как», а затем введите имя файла. Добавьте расширение .php в конец имени файла. Введите простое имя, например, version.php .

Изображение с названием 2232402 4 1

Узнайте подробную информацию (если хотите). Приведенный выше код отобразит версию PHP, но если вы хотите получить дополнительные данные, например, информацию о системе, дату сборки, доступные команды, информацию об API и так далее, используйте команду phpinfo () . Сохраните файл как info.php .

Источник

How to Check PHP Version

Hosting providers are traditionally slow to adopt new PHP versions on their servers. The consequence of this is that many different PHP versions exist on the web at the same time.

If you are implementing new features, installing a new PHP-based app, or trying to locate a bug on your website, it is important to know which PHP version your web server is running.

In this tutorial, you will learn how to check your PHP version by running PHP code on your server or using the command line.

How to Check PHP Version

Check PHP Version by Running PHP Code

The simplest method to determine the PHP version running on your website is executing a PHP file that contains the following code:

Create the file using a text editor like gedit or Notepad, and upload it to your website’s document root directory.

Then open a web browser and type the full address of the file in the address bar. For example, if you uploaded a file titled phpinfo.php to the example.com root directory, you would go to:

http://www.example.com/phpinfo.php

The code above displays the PHP version without any further details, like in the output below:

Checking PHP version by using the phpversion command

If you need more details on your PHP configuration, such as system information, build date, server API, configuration file information, etc., upload a file containing the phpinfo() function:

When visited in the browser, this file shows the PHP version in the upper-left corner, followed by configuration data:

Checking PHP version by using the phpinfo command

Note: While phpinfo() is useful for debugging, the page features sensitive information about your system. Remove the file from the server once you finish using it.

For a list containing all the loaded PHP extensions and their versions, upload a file with the following code:

The output shows each extension in a separate line, including the version of the PHP core:

Checking versions of loaded PHP extensions

Check PHP Version Using the Command Line (Windows, Linux and macOS)

If you have permission to SSH into the remote server, use the command line to check the installed PHP version. This method is also useful for checking the PHP version installed locally.

2. The php -v command works on Linux, macOS, Windows, and other supported systems. Its output contains the PHP version number, build date, and copyright information.

Checking PHP version by using the command line in Ubuntu

Note: If there is more than one PHP version installed on the server, the php -v command shows the default command-line interface (CLI) version. This version is not necessarily the one that runs on the hosted websites.

Fix ‘PHP is not Recognized’ Error on Windows

On Windows, the PHP path is sometimes not recognized by the system, so the php -v command outputs the ‘php is not recognized’ error.

The

To solve this problem, set the PATH environment variable first.

1. Type the following command, replacing [location] with the path to your PHP installation.

Setting the PATH variable for php.exe in Windows

2. Typing php -v now shows the PHP version installed on your Windows system.

Note: Check out our other PHP guides such as How to Make a Redirect in PHP or 4 Different Types of Errors in PHP.

This article aimed to explain the common ways to check the PHP version on your server or local machine. The methods covered in this tutorial include running PHP code and using the command-line interface.

Marko Aleksić is a Technical Writer at phoenixNAP. His innate curiosity regarding all things IT, combined with over a decade long background in writing, teaching and working in IT-related fields, led him to technical writing, where he has an opportunity to employ his skills and make technology less daunting to everyone.

A PHP Error occurs when something is wrong in the PHP code. An error can be simple as a missing semicolon.

If a script is not written correctly, or if something unusual happens, PHP can generate an error message.

Источник

Читайте также:  Python execute many sql
Оцените статью