Tom is a web developer, a Ph.D student researching software best practices, and university lecturer from the UK with an interest in programming best practices, separation of concerns and a less is more approach to code.
Before joining Culture Amp in 2015, Kevin taught a generation of web developers during his time at SitePoint, starting with the first edition of the book that you now hold in your hands. While there, he helped to launch success stories like 99designs and Flippa. More recently, he quizzed web developers on HTML, CSS and JavaScript by leading the team behind Sit the Test, and has spoken at tech conferences around the world. On weekends he performs improvised theatre with Impro Melbourne, which is a lot more like building websites than you might expect.
SitePoint specializes in publishing fun, practical, and easy-to-understand content for web professionals. Visit http://www.sitepoint.com/ to access our blogs, books, newsletters, articles, and community forums. Youll find a stack of information on JavaScript, PHP, Ruby, mobile development, design, and more.
Preface
It was 1998, I was twelve, and my parents had just bought the family our first modern PC. It wasnt long before I had figured out how to change the code for one of my favorite first-person shooter gameslittle things like making the rocket launcher fire a hundred rockets a second instead of one, then having it fire a hundred rockets in every direction and promptly crashing the game. I was hooked, and Ive been programming ever since.
The game was multiplayer. Other people had also discovered how to change the code, and the arms race quickly escalated. Someone would fire a hundred rockets at me. Id have a script ready that would instantly build a wall right in front of me to block them all.
My opponent would spawn a dozen land mines underneath me. Id turn off the gravity, then jump, soaring away from the impending explosion. Everyone could fly. It got to the point where it was no longer fun. Youd enter a game and someone had written a script to teleport you to the other side of the map, kill you instantly and force you to respawn, repeating the process a dozen times a second. Theyd freeze your controls too, of course.
We discovered ways to block all this, but by the end it was a stalemate. Whoever managed to enter the game first could take complete control of it, and no matter how good your scripts were, there was nothing you could do. It was fun while it lasted.
Thats how I learned the basics of coding, and that the only limit is your own imagination and creativity. During that time, Id also taught myself HTML, and had my own website where I shared some of my game hacking techniques and scripts. No, the website is not still up. Yes, it was terrible, full of bad grammar and cheesy animations (which was the style at the time, I promise!).
By 2000, I had taught myself the basics of PHP/MySQL and was running a website for a group of fellow gamers. I wrote some crude PHP scripts for posting news on the website, as well as polls, and even a script for handling our mini-tournament rankings and fixtures.
After that, I moved onto writing desktop applications in a horrible language called Delphi, writing tools that aided people in modding various games. I graduated from University in 2007 with a degree in Software Engineering, worked for various companies as a PHP developer, and these days Im back at the University studying for a PhD and working as a lecturer, spreading my passion for programming.
Im 31 now, and Ive been programming for more of my life than not. Its fun, its something I thoroughly enjoy doing. Im writing this book to share my knowledge with you and help you steer clear of some traps that are easy to fall into.
Learning to code is very enjoyable and rewarding. You can watch your program come alive as you build it. However, it can also be an incredibly frustrating experience. In this book, Im going to try to use my own experience to give you a smoother ride than I and a lot of developers have had. I can steer you in the right direction from the start.
Before I introduce you to any code, Im going to give you some general advice about programming and learning to code which I give to all my students.
Who Should Read This Book
This book is aimed at intermediate and advanced web designers looking to make the leap into server-side programming. Youll be expected to be comfortable with simple HTML, as Ill make use of it without much in the way of explanation. No knowledge of Cascading Style Sheets (CSS) or JavaScript is assumed or required, but if you do know JavaScript, youll find it will make learning PHP a breeze, since these languages are quite similar.
By the end of this book, you can expect to have a grasp of whats involved in building a modern PHP website, the basics of PHP, and tried and tested techniques that are used by developers today.
Programming Has Changed
As a novice developer starting now, theres a lot more you need to know before you can publish a website than someone who was building a website in 2001.
When I started, it was a much simpler time. For example, website security wasnt much of a consideration. Unless you were a bank or a company taking credit card payments, there was very little chance anyone would target your site.
These days, however, every single website is constantly bombarded by bots and scripts specifically looking to exploit even the smallest doors you may have left open.
The way PHP scripts are written has changed dramatically as wellcertainly for the better. Its now much, much easier to download and use someone elses code in your own project. The downside to this is that you need a much broader understanding of programming concepts before you can do anything useful.