PHP Tutorials

PHP tutorials from A to Z; these tutorials should cover most things that you will ever need to know about PHP. Help spread the word by linking and sharing!


Edited: 2021-02-06 03:34

Learn PHP

PHP tutorial

PHP is a general-purpose scripting language that is mostly used to create the server-sided parts of web-based applications. It was originally designed by a Danish programmer named Rasmus Lerdorf in 1995, and has since evolved into one of the preferred scripting languages among web developers.

While PHP can be used to create text-output in the form of HTML and XML, it can also be used to manipulate video and images — many people do not realize how powerful PHP can be as a web development tool. In addition, PHP can also be used to stream video files, to learn how to implement a video streaming feature you should read this tutorial: Streaming With PHP

PHP will also serve as a solid CLI scripting language, and in Linux environments you can even use it instead of Bash; all this requires is that PHP is installed on the system.

How long will it take to learn PHP

While there is no definite answer to this, since it depends largely on the individual, PHP is generally a very easy language to learn. Learning PHP before learning C++ and other compiled languages will sometimes be a easier route to take if you plan on learning a compiled programming language.

Learning PHP does not have any prerequisites, but it is certainly an advantage to know a little HTML and CSS if you want to create more than just CLI applications. If you have not yet learned HTML or CSS, then it is important that you look at these more like "one standard" that you need to learn rather than two separate things; this is because HTML and CSS is used so closely together today that it is hard to avoid using one without the other when designing web pages.

It is also important to remember that you do not need to memorize everything; you just need to get a basic understanding in order to use the relevant references when working on a project – memorization will come with time, use, and repetition. If you use a modern web development tool like Visual Studio Code, then there will also be build-in references when you hover the mouse over PHP functions.

Getting started

1. To use PHP you usually install a HTTP web server; Apache is free and remains one of the most popular web servers in use on the internet. For Debian/Ubuntu users, Apache may be installed easily from terminal:

apt install apache2

Windows users should download the Windows version from The Apache Foundations website: Downloading the Apache HTTP Server (

2. It is now time to install PHP on the system. Again, if using a Debian or Ubuntu based system, you probably just need to type the following command in a terminal:

apt install php8.0 libapache2-mod-php8.0

If you are on a Windows system, you should find the Windows version of PHP; this can be found at:

3. Now that you got both Apache and PHP installed, you just need to connect Apache with PHP. On a Linux system you got a couple of choices — you can either enable Apache's mod_php, or you can setup PHP-FPM. For simplicity, let us stick with Apache for this part:

a2enmod php8.0

You should now be able to start coding web-application in PHP. For Linux, the website root is often located at /var/www/. You can create a file in this directory to see if everything was setup correctly, so let's create the /var/www/phpinfo.php file:


We may open this file by typing in http://localhost/ in a browser's address bar. When opened in a browser, this file will display various information about your server, which is useful for testing and debugging.


  1. - the official PHP documentation
  1. How to use the AVIF image format in PHP; A1 or AVIF is a new image format that offers better compression than WebP, JPEG and PNG, and that already works in Google Chrome.
  2. How to create a router in PHP to handle different request types, paths, and request parameters.
  3. How much faster is C++ than PHP to increment and display a counter in a loop?
  4. Detecting the request method used to fetch a web page with PHP, routing, HTTP responses, and more.
  5. How to create a custom error handler for PHP that handles non-fetal errors.

More in: PHP Tutorials