When we refer to “PHP” in this book, by “PHP 7” we mean any PHP distribution greater than or equal to PHP 7.2.

Install it under GNU/Linux

For GNU/Linux users, you can install PHP 7 using the distribution’s package manager. For example, on Debian and Ubuntu, you can type sudo apt update && sudo apt install php7.2.

To verify that the installation was successful, you can start the Terminal program by opening the Terminal application or by pressing Alt + F2 and typing gnOMe-Terminal. If this does not work, consult the documentation for the GNU/Linux distribution you are using. Now run the PHP command to make sure it doesn’t have any errors.

You should see PHP version information displayed on the screen after running the command:

$PHP -v PHP 7.2.9-1+ubuntu16.04.1+deb.sury.org+1 (cli) Copyright (c) 1997-2018 The PHP Group Zend Engine V3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.9-1+ubuntu16.04.1+deb.sury.org+1 Copyright (C) 1999-2018, by Zend Technologies with Xdebug V2.6.0, Copyright (C) 2002-2018, by Derick RethansCopy the code

Note: $is the Shell prompt. This will vary depending on the setup of the operating system on which your computer is running, and I’ll use the $sign to represent the prompt later in this article.

Note: The output will vary depending on your computer, depending on what version of PHP you have installed on your computer.

Install it on Mac OS

For Mac OS X users, you can use Homebrew and install with the command brew install [email protected].

To verify that the installation is successful, press [Command + Space] (to start Spotlight search), type Terminal, and press [Enter] to start the Terminal program. Now, try running the PHP command to make sure it doesn’t have any errors.

Install on Windows

Visit php.net/downloads.p… And download the latest version of PHP. At the time of writing, the latest version is PHP 7.2. The installation process is the same as that of any other Windows software.

Then, set PATH to the root directory where your PHP is located (the folder where php.exe is located) so you can execute PHP directly from the command line.

In Vista, Windows 7, and Windows 8, we can use the setx command to set the path from the command line.

setx path "%path%; c:\directoryPath"
Copy the code

conclusion

From now on, we will assume that you have PHP installed on your system.

Next, we’ll write our first PHP program.

Link: blog.zhanxiaobai.com/2018/08/27/…