Object Oriented PHP
Looping and Recursion
cURL HTTP Requests
HTTP Server Responses
PHP Error Handling
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.
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 (httpd.apache.org)
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: https://windows.php.net/download
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:
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.
- php.net - the official PHP documentation