The tutorial is explicitly aimed at beginner programmers. Experience in other programming languages is not required. However, you should already know the basic of HTML.
PHP is not to be confused with web design. The design of a website continues to be done using HTML and CSS, PHP is used to add dynamic content to the server side of a page, such as loading user data from a database. In this tutorials, we assume that you have basic HTML and CSS knowledge. PHP is a server-side programming language, which means you can dynamically load data from the server.
Our PHP tutorial is arranged as follows to give you a structured and straightforward introduction to PHP:
This article describes how to get an Apache server up and running on your machine. We need this server to run a PHP script.
With opening <?php tag, you can define PHP script environments in your scripts. These script environments can alternate with common HTML commands.
Echo can be used to output texts and variables in PHP.
Comments serve to make your program code clearer. In PHP, you can define it either by two slashes (//) or by a hash (#). Multi-line comments are possible if they start with a / * and end with * /.
With variables, values such as texts or numbers can be saved and further modified. This article also describes how to pass values between pages.
This article explains how PHP and variables can be used to perform mathematical operations such as adding or subtracting.
With $ _GET and $ _POST, values, such as one-user form input, can be transferred between different PHP pages.
With if statements you can check values and variables in PHP, for example, which variable is more significant.
Using the comparison operators ==,! = Etc., you can compare values and variables, for example, if they have the same value.
With logical operators such as OR and AND, we can perform complex variable checks.
This section is a short tutorial with various tasks that you can already implement with the knowledge you have gained so far.
Using a while loop, we can count in PHP, for example, incrementing a variable up to a particular value.
A loop instructs PHP to execute specific commands as long as the condition of the loop is true. One possible type of loop is the for loop.
Arrays allow us to store lists in variables, such as a list of all our users.
In PHP the functions file_get_contents() and file() can be used to read files. file_get_contents() reads the entire file and returns the content as a string. file(), on the other hand, reads the file line by line and returns an array.
With the file_put_contents() function, values can be written to a file. The file can either be overwritten, or the value can be attached to an existing file.
Date and Time
This tutorial covers the date and time functions in PHP. You will learn how to spend the current date and how to calculate dates, for example, to determine the time in a month.
Sending e-mails with PHP E-mails
An e-mail can be sent very simply using PHP. In this tutorial, you will learn how to do this.
Find and Replace
In this tutorial, you will learn how to check if a text contains a specific search term and how you can automatically replace the search terms.
Sessions are used to save states from previous page views. For example, if you would like to know with which user name the visitor logged in, you have to keep this information in one session.
Create own functions
If you write more complex code, it is advisable to write frequently used functions as a separate function.
Include Other PHP Files
Clearer code makes your job easier. In this tutorial, you will learn a few tips.
How does the upload of files from the user to you on the web space work? This article will show you how to do this quickly and safely.
Cookies can be used to permanently store data in the browser of a visitor, for example, his username.
Constants can be used to define fixed, non-variable values in PHP.
Regular expressions allow us to check and search texts for complex patterns. For example, Internet and e-mail addresses can be identified.
The most essential PHP functions at a glance
Typically, you only use a few dozens of the hundreds of functions that PHP offers. That's why we have put together the most important functions for you in this list.