PHP Tutorials for Beginners

You have probably heard that PHP is much easier to learn than any other programming languages, such as Java or the .NET languages, not to mention Perl, but if you are new to PHP, it can be daunting. If you are new to PHP, we are here to help.

The first block of PHP tutorials are more general and cover the basics of PHP as a language, such as variables, conditionals, HTML forms, loops, arrays, strings, functions… While the second block of tutorials are all about performing a particular task, such as creating captchas, building forms, and even building a complete CMS.

Now remember, take your time with each tutorial and enjoy!

PHP tutorial Logo

A Simple Tutorial from php.net

It doesn’t matter what kind kind of information you are looking for, it is always best to start at the source. This, of course, applies to learning PHP as well, the very site of the PHP programming language: php.net.

I am not saying this tutorial is the easiest, but it is a great tutorial for getting started with. It is more like a general introduction to PHP than a complete guide. Iit is split into the following sections:

  • What do I need?
  • Your first PHP-enabled page
  • Something Useful
  • Dealing with Forms
  • Using old code with new versions of PHP
  • What’s next?

The tutorial should only take you about 15 minutes to complete – providing you don’t check all the hyperlinks to the other pages. If you do, it will probably take weeks to complete.

A Simple Tutorial from php.net →

Beginners PHP (Complete Course)

This tutorial is a much longer and more in-depth that the tutorial above. It covers all the basics of PHP, such as variables, conditionals, HTML forms, loops, arrays, strings, functions, security, file manipulation, MySQL, user authentication. At the end of the tutorial you will find chapters on how to code sample apps, such as polls and online forums.

This is a long tutorial and you may have to go through some chapters more than once, especially if you are new to PHP. So, you will need at least a day or two to go through it all.

Beginners PHP →

Introduction to PHP (Complete Course)

If you are a fan of video tutorials, then you will love this PHP Course. There are over 200 videos available and they cover absolutely everything about PHP. The series covers all aspects of PHP, such as how to install XAMMP, how to create your first PHP file, input/output, variables, conditionals, operators, loops, commonly-used functions, strings, arrays, sample applications, etc.

It’s a huge resource and if you want to learn absolutely everything, you will need weeks to cover it all. Each video is reasonably short, though – from 1 to 10 minutes, so you can watch a couple of them in a day, revise them on the next day, and thenmove onto the next video.

Introduction to PHP →

PHP 101: PHP For the Absolute Beginner (Complete Course)

This is another complete PHP course that walks you through the basics. As with the other courses, it covers everything – variables, operators, loops, functions, arguments, MySQL, object oriented programming, sessions and cookies, error handling and security. It even includes two tutorials for building sample applications – such as a simple web application and an RSS news aggregator. Similarly to the other complete courses, this one will take at least a couple of days to read, learn, and revise.

PHP 101: PHP For the Absolute Beginner →

MySQL PHP Tutorial

The tutorials so far include sections on MySQL and how to use it with PHP, but since PHP and MySQL are used together [almost] all the time, it wouldn’t hurt to cover a tutorial that focuses solely on MySQL.

This tutorial explains how to create a new MySQL database, connect to it, create users and give them permissions, write a simple script, create and populate a database, retrieve data, escape characters, print column headers, count fields and rows, write and read images, and use transactions.

The following is a simple PHP script example from the tutorial:

<?php

$host = "localhost"; 
$user = "user12"; 
$pass = "34klq*"; 

$r = mysql_connect($host, $user, $pass);

if (!$r) {
    echo "Could not connect to server\n";
    trigger_error(mysql_error(), E_USER_ERROR);
} else {
    echo "Connection established\n"; 
}

echo mysql_get_server_info() . "\n"; 

mysql_close();

?>

If you are already familiar with the SQL syntax this tutorial should only take you 2-4 hours.

MySQL PHP Tutorial →

PHP OOP Tutorial from Beginner to Advance

This multipart tutorial series focuses on PHP from the object oriented programming (OOP) point of view. It starts nice and gently, so even if you are a beginner to both PHP and OOP, you will be able to follow along easily. The first part covers the basic concepts of OOP, such as objects, abstraction, inheritance, encapsulation, and polymorphism, but the following parts delve much deeper.

This tutorial will take you no more than 15 minutes (including the time you need to test the examples). However, the foloowing tutorials in the series are much longer and more complicated, so for each of them you might want to devote half an hour or more.

PHP OOP Tutorial →

List Files and Directories with PHP

Lists of files and directories are very common in web development. This tutorial will show you how to list files and directories with the glob() function, a combination of the opendir(), readdir() and closedir() functions, and the scandir() function. You will also learn some advanced file/directory listing techniques – SPL iterators, such as the FilesystemIterator, the RecursiveDirectoryIterator, and the GlobIterator.

The tutorial isn’t as complex as it might at first seem, but you probably should budget at least 45 minutes to complete it. It could even take longer, if everything is not working as expected and you need to make some fixes.

List Files and Directories with PHP →

Creating Your First PHP Application

We are definitely way beyond the basics with this tutorial. In fact, it’s a series of tutorials that cover the following:

Part 1 – Setting up the project and creating your first class

  • Creating an outline of the project
  • Setting up your files and folders
  • Creating a class to handle database operations: DB.class.php

Part 2 – Building the rest of the backend

  • Creating a User class
  • Creating a UserTools class
  • Registration / Logging in / Logging out

Part 3 – Building the front end

  • Forms
  • Form Handling
  • Displaying session data

As you can see this is a large tutorial, so budget at least a couple of days to complete it.

Creating Your First PHP Application →

How to Process Credit Cards with PayPal Payments Pro Using PHP

For a shopping site, credit cards payments are a must. There are many ways to accept credit card payments but PayPal is the most popular. In order to complete this tutorial you will need to have a merchant account with PayPal. The steps you need to follow are: create the directory structure, setup the config file, create an API request, send the HTTP request to PayPal, and parse the API response (there two approaches).

This isn’t the simplest tutorial, so you will probably need at least an hour or so to complete it.

How to Process Credit Cards with PayPal Payments Pro Using PHP →

Automatic CSS3 Prefixer and Compressor Tutorial

CSS files are text files but they can be very large. That is why they will benefit from some compression. Additionally, instead of writing all CSS3 properties with browser-specific prefixes by hand, this can be automated with PHP.

Automatic CSS3 Prefixer and Compressor php Tutorial

This tutorial will teach you exactly how to do this: Generate CSS3 properties with browser-specific prefixes, how to concatenate (had to look this word up, it means ‘ linked together, as in a chain’ – Editor) all the CSS files to save space and reduce load time, and how to do both automatically when a web page is requested.

The estimated time to complete the tutorial is about an hour.

Automatic CSS3 Prefixer and Compressor Tutorial →

Create Your Own Captcha in PHP

This short tutorial has been written in a typical programmer’s fashion, meaning it has little to no explanation, short to missing comments, and the assumption that everything is obvious and clear. However, aside from this, it is a useful tutorial and the slightly more advanced programmers might love it just because it uses few words and plenty of code.

Create Your Own Captcha in PHP tutorial

The tutorial is short, so it won’t take you more than 20 minutes.

Create Your Own Captcha in PHP →

Getting Started with PHP Regular Expressions

And now a tutorial on everybody’s favorite: regular expressions. Unfortunately for everybody who hates them, regular expressions are pretty useful, though often you can bypass them with other techniques.

Create Your Own Captcha in PHP tutorial

The tutorial in the link explains what regular expressions are, the Perl compatible regular expressions, the basic syntax of PHP regular expressions, how to use regular expressions in PHP, useful regex functions. Additionally, the tutorial includes a cheat sheet where all the basic stuff is gathered in one neat place.

The tutorial could take you an hour or two to complete but this depends on your familiarity with regular expressions. If you are a total stranger to them, expect to read some sections multiple times and, naturally, this will take you much more time.

Getting Started with PHP Regular Expressions →

Simple Banner Rotator With PHP, jQuery & MySQL

This tutorial goes beyond PHP, but since in real life that is exactly what you need, that is why the tutorial is included here. First you need to create the database schema, then the XHTML code, then the CSS, and only after that you will move on to the PHP side of things.

Simple Banner Rotator With PHP tutorial

The tutorial will take you at least 2 hours to complete, and that is if you don’t have to make a lot of modifications to the code.

Simple Banner Rotator With PHP, jQuery & MySQL →

Build a CMS in an Afternoon with PHP and MySQL

If we are honest here, this tutorial will probably take you more than an afternoon to complete. Having said that, it also isn’t as hard as it seems. In order to create the CMS, you do need to be familiar with the SQL syntax and MySQL, so if you do lack knowledge in these areas, first check the tutorials that teach MySQL above and then come back to this one.

Build a CMS in an Afternoon with PHP and MySQL

The CMS you will be learning to build will have all of the basic features you would expect from a CMS.

The frontend will have:

  • Homepage with the 5 most recent articles
  • Article Listing Page (archives), where snippets of all articles are displayed
  • A "View Article" page (single post), where visitors can read the entire article

The backend will have:

  • Admin login/logout
  • List of all articles
  • Add a new article
  • Edit an existing article
  • Delete an existing article

Build a CMS in an Afternoon with PHP and MySQL →

PHP Script Image of the Day

This tutorial shows you how to create a PHP script image of the day. All you need to do is find today’s date (with the help of the date function), store the value in the "$today" variable, and compare $today with the name of the day. Then you display the message "Today is " … " (you can modify the message, of course), together with the image of the day.

PHP Script Image of the Day

The estimated time for the completion of the task is about 10 to 15 minutes. This however doesn’t include the time to search for the images to display every day, so you may want to prepare them in advance.

PHP Script Image of the Day →

PHP is fun and it can be used for so many tasks. These tutorials won’t make you a PHP guru but they will help improve your skills and hopefully allow you to develop more complex PHP applications.

Author: (26 Posts)

Ada is a fulltime freelancer and enjoys every second of it. She is also the Blogger Relations Manager at WinkPress.com, which is a web resource about leveraging WordPress, its themes, and plugins to create versatile and unusual websites.

Comments