HSHimanshu Sharma
Courses

Learn PHP for free: a 54-lesson course from your first script to a database

Advertisement

PHP is the language behind a huge share of the web. WordPress is written in it, Laravel is built on it, and millions of small business sites, shops and admin panels run on it. It is also one of the easiest server languages to start with: you write a file, put it on a server, and a web page appears. The free PHP course on this site takes you from installing PHP to building a small database-backed web application, in 54 short lessons. This post explains what is in the course, how it is organised, how long it takes and how to get the most out of it.

Who the course is for

The course assumes no previous programming experience. Basic HTML helps, because PHP produces HTML, and the HTML course covers what you need. If you have already written code in another language, you can move faster through the early lessons. The later database lessons pair well with the MySQL course.

You need a computer on which you can install software and a text editor. There is nothing to buy, and there is no account needed to read the lessons.

How each lesson works

Every lesson is built the same way, so you know what to expect:

  • A short explanation of one idea. Lessons are designed to take about ten minutes.
  • Code examples with their output. The output shown is not guessed: every example in the course is run with real PHP, and the printed result is checked against what the lesson claims. That is how the course catches mistakes such as a wrong prediction about type juggling.
  • A quiz of a few questions at the end, with an explanation of each answer.
  • Common mistakes and an exercise with a hidden answer you open after trying it yourself.

Reading is not enough for programming. Type the examples, change them, break them and fix them. The exercise at the end of each lesson exists to make you do that.

The ten sections

Section Lessons What you learn
Getting started 4 What PHP is, how to install it, your first script, syntax and comments
The basics 8 Variables, data types, strings, numbers, constants, operators, comparisons and echo
Control flow 5 if, switch and match, loops, the ternary and null-coalescing operators
Functions 5 Writing functions, typed parameters, scope, closures, splitting code into files
Arrays 5 Indexed and associative arrays, multidimensional arrays, sorting, array_map, array_filter, array_reduce
Strings, dates and patterns 4 String functions, Unicode text, regular expressions, dates and times
PHP on the web 7 Mixing PHP and HTML, forms, validation, headers, cookies, sessions and file uploads
Files, data and errors 3 Reading and writing files, JSON, errors and exceptions
Object-oriented PHP 8 Classes, constructors, inheritance, interfaces, traits, static members, enums, namespaces and Composer
Databases and security 5 PDO, CRUD with prepared statements, password hashing, web security and the final project

The order matters. You learn to store and transform data with arrays and functions before you meet forms, so that when a form sends you data you already know what to do with it. Object-oriented programming comes after you can write working procedural code, because classes make more sense when you have felt the problems they solve.

What makes the PHP course different

Modern PHP. The lessons use current features: typed parameters and return values, match, enums, readonly properties, named arguments and the null-safe operator. You do not learn habits from the PHP of fifteen years ago.

Security from the start. Forms, sessions and databases are where beginners write vulnerable code. The course teaches escaping output, validating input, prepared statements, password hashing and protecting forms against CSRF, with examples of the attack and the fix. One real example from writing the course: a CSRF check that accepted an empty token on a new session, because two empty strings compare equal, which is the kind of bug a lesson on hash_equals is there to prevent.

Verified output. Because examples are really executed, the lessons show real error messages, real warnings and real results, including the surprising ones.

The final project

The last lesson is a guestbook with a database. You build a small application that shows entries, accepts new ones through a validated form, stores them with PDO and prepared statements, escapes everything it prints and protects its form. It is deliberately small, but it uses the course end to end: files, functions, arrays, forms, sessions, classes and the database. A learner who can build it from a blank folder has moved from reading about PHP to using it.

How long it takes

At about ten minutes of reading plus the same again for typing the examples and the exercise, a lesson takes 20 to 30 minutes. For 54 lessons that is about 18 to 27 hours of work. Here are three realistic ways to spread it:

Pace Time per day Finishing time
Relaxed 1 lesson a day about 8 weeks
Steady 2 lessons a day about 4 weeks
Intensive 4 lessons a day about 2 weeks

A slow, steady pace usually works better than a sprint. If you stop for a week, reread the last lesson before you continue.

The exam and the certificate

When you complete every lesson, the final exam unlocks. It has 15 multiple-choice questions drawn at random from a bank of 40, 30 minutes and a pass mark of 70% (11 correct answers). You can try three times in any 24 hours. If you pass, you receive a certificate with your name and a public link that anyone can open to check it is genuine. The details are in PHP certificate: how the final exam works.

You do not need to take the exam. Many learners use the course only to learn. But if you want proof of completion for a CV or a portfolio, the exam and certificate are there.

What you can build afterwards

After the course you can:

  • build a contact form that validates input and saves it,
  • build a small login system with hashed passwords and sessions,
  • write a script that reads and writes data files or JSON,
  • connect to MySQL and build create, read, update and delete pages,
  • read WordPress or Laravel code and understand it, since both are PHP.

For the next step, a good path is to learn how to design the database properly with the MySQL course, or to move into WordPress development with the WordPress course, which relies on the PHP you learn here.

Tips for finishing

  1. Install PHP and run every example yourself. The lesson on installing PHP shows how to run scripts from the command line and with the built-in web server.
  2. Use the exercises. Attempt before opening the answer.
  3. Keep a small project folder where you save your own versions of the examples. It becomes your reference.
  4. Read error messages. PHP tells you the file and line. Learning to read them is half of programming.
  5. Do not skip the quizzes. They check understanding, not memory.
  6. Make an account if you want your progress to follow you between devices and to take the exam.
  7. Build something of your own after the guestbook, even something silly. Teaching yourself to start from a blank file is the real skill.

Quick answers

Do I need to know HTML first? It helps, but the lessons explain the little you need.

Is the course really free? Yes. There is no payment for lessons, the exam or the certificate.

Which PHP version does it use? A current, supported version, and it points out features that need a recent one.

Is the certificate an official qualification? No. It is proof that you completed this course and passed its exam, which you can show alongside real projects.

Can I learn PHP without the MySQL course? Yes, but the database lessons are easier if you have seen SQL before.

Advertisement