Learn how to use PHP with step-by-step installation guides for Windows and mobile phones. Set up PHP using XAMPP, manual installation, or VS Code. Start coding PHP today!.
To use PHP on Windows, you need to set up a local development environment that can run PHP scripts. Here are 3 main ways to do it:
XAMPP is a free and easy-to-install package that includes Apache (web server), MySQL, and PHP.
XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl. The XAMPP open source package has been set up to be incredibly easy to install and to use.[6]
Download XAMPP:
Go to https://www.apachefriends.org/download.html and download the Windows version.
Install XAMPP:
Run the installer and choose to install Apache and PHP (MySQL is optional).
Start Apache:
Open the XAMPP Control Panel and click Start next to Apache.
htdocs
folder (usually in C:\xampp\htdocs
), e.g.:
<?php
echo "Hello, PHP!";
?>
http://localhost/yourfilename.php
Download PHP:
Get it from https://windows.php.net/download (choose the Thread Safe version for use with a server).
Extract PHP:
Unzip it to a folder like C:\php
.
Configure Environment Variable:
Add C:\php
to your system PATH
.
php -v
You should see the PHP version.
test.php
with:
<?php
echo "My first php page.";
?>
Then run:
php test.php
for more details, see How to install php
.php
files.php -S localhost:8000
) to test in a browser.Step 1: Use a Code Editor App
Since PHP is a server-side language, you need an environment that supports it. Try these mobile apps:
Step 2: Install AWebServer (Apache, PHP, SQL) on Android Phone
for more details, see How to Install AWebServer (Apache, PHP, SQL) on Android Phone
Since installing a local server on a phone is tricky, online compilers are a great alternative:
Some free hosting services allow PHP execution, such as:
[1] AWebServer – PHP, MySQL, FTP [Mobile App], Ice Cold Apps. [Online]. Available: https://play.google.com/store/apps/details?id=com.icecoldapps.awebserver
[2] phpMyAdmin Team, phpMyAdmin. [Online]. Available: https://www.phpmyadmin.net/
[3] Apache Software Foundation, Apache HTTP Server Documentation. [Online]. Available: https://httpd.apache.org/docs/
[4] PHP Group, PHP Manual. [Online]. Available: https://www.php.net/manual/en/
[5] MariaDB Corporation, MariaDB Knowledge Base. [Online]. Available: https://mariadb.com/kb/en/
[6] Apache Friends, XAMPP - Apache, MySQL, PHP, Perl. [Online]. Available: https://www.apachefriends.org/