Getting Started with PHP

Introduction to PHP
Echo and print

Previously, in our Introduction to PHP, we discussed the real basics of PHP. We went into detail about what PHP is, the features and uses. Next in this article we show you how to install and run PHP as quickly and easy as possible.

Install PHP and MySQL with XAMPP 

In the next part we will discuss XAMPP. Before continuing I recommend you to download this software below.

XAMPP – [download / more info]

PHP simply doesn’t work stand-alone. For you to be able to run it you need a web server. Apache is most used and with good reasons. And at some point you also would want to run a database (for which XAMPP doesn’t only provide MySQL, but also PHPMyAdmin – an excellent WYSIWYG database tool).

Now, if you want to spend days installing and tweaking things and solving errors the best route is to install all of this separately.
However, if you, like most of us, prefer the quick and easy route then XAMPP is much recommended.

XAMPP, that is a weird name? Yes, it is, but that is because it is an acronym of the following:

X – Refers to cross-platform. You can use XAMPP on Windows, but also on MacOS and Unix/Linux.
A – The A stands for Apache HTTP Server.
M – Stands for MariaDB (which formerly was MySQL)
P – Perl (a programming language which used to be quite popular, see Perl on Wikipedia)

If you prefer a more custom approach, or a more light-weight approach, then installing every package yourself is still an option. The big advantage is that it will give you better control.

Here are the packages:

Apache HTTP Server – [download / more info]
PHP – [download / more info]
MySQL [download / more info]
PHPMyAdmin [download]

Video: XAMPP tutorial for beginners

Install Xampp on Windows

You can follow the instructions below for installing XAMPP on Windows.

  •  Download the .exe file, click it to start installation

  • Click Next and select the components you wish to install. By default they are all checked. If you have enough space then I recommend to keep them all checked. If space is an issue you can uncheck FileZilla FTP Server and Mercury Mail Server. Also Perl is a programming language you probably will never touch.

  • The next step is to select your desired location where you want to install it. Click Next to begin the installation. 

  • On the next screen click Finish to complete the installation process. 
  • You have successfully installed XAMP for Windows.

Installing Sublime Text

Now that you installed XAMPP our next task is a text editor. You can write a PHP script with Notepad, but it isn’t that comfortable. What you want is an editor that recognizes PHP code.

Sublime text editor is an excellent editor for coding and markup languages. The latest version is Sublime Text 4 which comes with many new features. You can grab a copy at and install the latest version for Windows. 

  • Scroll down and you will see the download for windows 64 bit.

  • Double click on the .exe file and click to install.
  • Select destination location, where you want to install Sublime. 

  • Click Next, click Install. 

  • It  will take a few seconds. After that click Finish and open Sublime text editor. 
  • Here is how it looks.

Running a PHP File

In order to run a PHP file you first should save it with the .php extension; Once saved you should save it to the following directory:

C: \xampp\htdocs

Make sure you are running XAMPP! After you verified that you can go to your browser and type in the following URL:

http://localhost/myfile.php (myfile.php should be replaced with the name of your PHP file)

Thank you for reading! I hope that this article gave you some renewed clarity about how to get started with PHP.

Introduction to PHP
Echo and print

Add comment

Tutor Network

Share this

Learn PHP from A to Z