Set Up Your Language · 11 of 14
Setting Up PHP
PHP is a language for building websites: it runs on the web server and produces the page your browser shows. WordPress, which runs a large share of the world's websites, is written in PHP. On Windows, PHP comes as a zip file that you unpack yourself, so this set-up has a few more manual steps.
New to all this? Read Before you start on the main page first: it shows how to open Terminal, make a folder for your code, and see file name endings. It takes five minutes and prevents most problems.
1 What to download, and from where
Download only from windows.php.net, the official PHP for Windows downloads, part of php.net. Other download sites can bundle unwanted software.
- Go to windows.php.net/download.
- Find the newest version at the top. Under it, look for VS17 x64 Non Thread Safe and click its Zip link. (VS17 tells you which Microsoft tools it was built with; "Non Thread Safe" is the right choice for running PHP from the command line.)
- PHP needs Microsoft's Visual C++ Redistributable. Download it from Microsoft: vc_redist.x64.exe (an official Microsoft link). Many computers have it already.
2 Install it on Windows
- Open
vc_redist.x64.exeand click Install. If it says it is already installed, close it; that is fine. - Make a folder
C:\php. - Open the PHP zip in your Downloads folder, click Extract all, and extract it into
C:\php. When done,C:\phpshould directly contain a file namedphp.exe(not another folder with it inside). - Add
C:\phpto your PATH (step-by-step instructions), then close and reopen Terminal.
3 Check that it worked
Close every Terminal window you have open and open a new one. A Terminal that was already open does not know about programs installed after it started. Then type this and press Enter:
php -vWhat you will see: A first line starting with PHP and a version number, then (cli), meaning the command-line version.
PHP 8.5.0 (cli) (built: Nov 18 2025 ...) (NTS Visual C++ 2022 x64) Copyright (c) The PHP Group
If you see an error such as "is not recognized" instead, look at the common mistakes at the bottom of this page.
4 Write and save your first program
A program is just a text file. You can write it in Notepad, which comes with Windows. (Later you may like the free Visual Studio Code editor from code.visualstudio.com, which colours the code and helps spot mistakes.)
- Open Notepad (press the Windows key, type Notepad, press Enter).
- Type the program below, or click Copy and paste it in with Ctrl + V. Every symbol matters, so copy it exactly.
<?php echo "Hello, World!\n"; - In Notepad choose File → Save as. Go to your
C:\codefolder. Set Save as type to All files (*.*), type the file namehello.phpexactly as shown, including the dot and the ending, and click Save.
<?php marks where PHP code begins. echo prints the text, and \n starts a new line.
Do not use Word. Word saves extra formatting and changes straight quotes " into curly ones “ ”, which no programming language accepts.
5 Run it and see the result
Open File Explorer, go into your C:\code folder, right-click an empty part of the window and choose Open in Terminal. (More ways to open Terminal.) If Terminal was already open from the check above and is in another folder, type cd C:\code and press Enter.
Type this and press Enter:
php hello.phpWhat you will see: the words below on a new line. That is your program running.
Hello, World!
See it in a browser: PHP has a small built-in web server for testing. In your folder run php -S localhost:8000, then open http://localhost:8000/hello.php in your browser. Press Ctrl + C in Terminal to stop it.
Congratulations: you have written and run a PHP program.
6 Common beginner mistakes and how to fix them
Error messages look alarming but are usually precise: read the first line, and look for a line number. If you are stuck, copy the whole error message and paste it into an AI assistant along with your code, and ask what it means.
The code execution cannot proceed because VCRUNTIME140.dll was not found
Why: the Microsoft Visual C++ Redistributable is missing.
Fix: install vc_redist.x64.exe from the link in the download step, then try again.
It prints the code itself instead of Hello, World!
Why: the first line <?php is missing or misspelt, so PHP treats everything as plain text to show as it is.
Fix: make <?php the very first thing in the file.
'php' is not recognized as an internal or external command
Why: Windows cannot find the program. Either the Terminal was open before you installed it, or the program's folder is not on the PATH (the list of folders Windows searches for commands).
Fix: Close every Terminal window you have open and open a new one. A Terminal that was already open does not know about programs installed after it started. If it still fails, restart the computer, then check the folder is on the PATH (how to check and add it). The folder to add is C:\php, and it must contain php.exe directly.