A Moderately Short PHP Tutorial

Introduction

Who is this for?

This is for anyone who wants to learn to program in PHP.

You should probably already know at least one programming language with curly braces, if conditions, variables, functions and loops. The most likely scenario is that you are a Javascript or Typescript developer, working on a team that uses a combination of PHP and JS or TS, and while you might not currently need deep PHP knowledge, you want 'T-shaped skills', involving basic PHP knowledge. There will be some comparisons with Javascript and Typescript.

Why did I write it?

I work as a PHP developer, and have some colleagues with great Javascript skills who sometimes want to do work in the PHP side of our application, but don't have PHP experience from their previous jobs. I looked around for an introductory tutorial to recommend they can work through, but I didn't find anything that seemed exactly right.

Approach

This is a step-by-step guide to using a selection of the most important aspects of PHP. It doesn't attempt to be comprehensive.

PHP is an old language that has evolved organically over the years. There are many ways to do things, and many parts of the language that are best avoided in new code. This tutorial will concentrate on recommended ways to use PHP, and ignore most of the things that PHP allows you to do but you probably shouldn't.