Foreword
You are about to learn the language that runs the web.
That is not a figure of speech. A large share of the sites you visit every day are written in PHP: Wikipedia, countless online shops, most blogs. WordPress alone powers more than four websites out of ten. You have probably never given it a thought, and that is normal. PHP has been doing its job quietly for thirty years.
You may have heard bad things about it. There is a reason for that. The PHP of fifteen years ago was messy, forgiving to the point of absurdity, and many people learned to dislike it back then. What they do not always know is how much the language has changed since. Today’s PHP is clean, fast, typed, and a pleasure to write. The reputation stayed where it was. The language moved on.
The PHP people complain about barely exists anymore. The PHP you are about to learn, few people really know.
That is good news for you: you start from zero, with nothing to unlearn. And you are in good hands. I have spent a large part of my life with this language, writing it, teaching it, analyzing other people’s code, and watching it grow. I know where the traps are, and above all, I know what you need to understand to walk right past them.
This book will never ask you to copy code you do not understand. Every idea is explained once, properly, with a drawing whenever a drawing says it better than a paragraph. You will move forward through small programs that work, from your first “Hello, world!” to a real website built with your own hands.
You need nothing more than a computer, some curiosity, and the urge to see what happens when you press Enter.
So open a terminal, install PHP, and let’s begin.