Introduction - The PHP Project Guide (2014)

The PHP Project Guide (2014)

1. Introduction

Most programming books will teach you the basics of the language, run through some example applications and perhaps give you some additional resources like a disc, or online resources that are barely updated if even touched by the author at all.

The problem with writing a book about a language is that things change, and even worse, all of the information within these books is freely available on the internet. Programming books can’t offer information about future security, speed and other issues within a language, simply because they don’t exist yet. You also finish a book with no idea of where to go next, or what to learn next. You may have gained knowledge about a language, its syntax, built in functions, etc., but what happens when you need to build your application? Do you really know how to piece together what you’ve learned?

This book has been written to guide you through PHP and give you the knowledge to move forward in building applications. It’ll guide you through almost everything you need to consider when writing PHP and how you can become a programmer who can build anything, not just by knowing everything, but learning how to address things you’re unsure of. This book aims to remove the stage that most people get to when learning a new language… the phase where you understand the language but aren’t fully flexible in building whatever you want.

1.1 Typical programming books are hard to learn from

In this book, we’ll take a problem or something we want to build and we’ll spend the majority of time discussing it instead of listing reams of code. This is sensible, because you simply can’t learn from looking at code. The more time that’s spent discussing and planning a project means you can then use the tools you need to build what you know how to. If you don’t understand how to perform a particular action within a programming language, that’s fine! The difference is after thorough thought is that you understand how to address it and can learn how to do it. Once you’ve learned the hard way to do something, it’s unlikely you’ll forget it. We’ll discuss this more in chapter How to learn.

1.2 Who this book is for

If you’ve learned PHP and you don’t feel you’re as flexible as you can be with taking building applications to the next stage, then this book is for you.

No PHP code knowledge is required for this book, so you can read this before you even begin learning. On the other hand, if you feel you’re really good at the language, have learned everything you feel you can but can’t quite put everything together, this book is for you.

We’ll also discuss some general topics that apply to most web applications, like best practices, caching and security, so you may benefit from this book if you’re already building applications but want to gain some additional knowledge that will help you on your way. Because of these general topics, you may find this book helpful if you’re working with another web-based language.

1.3 What you should get from reading this book

This book teaches you how to learn better and gives a general insight into web development with a focus on PHP. By the time you’ve finished reading this book you’ll have a better understanding of development process, resources and practices you need to be able to work confidently on a product. This book doesn’t cover absolutely everything you need to know, nor will it teach you everything you need to know about PHP, but you’ll be able to build on what’s written on the following pages and use the help and advice to achieve your goals.

1.4 Useful notations

As this book is very conversational and contains more text than code, you won’t find it filled with pages of code. Where any code is displayed, you’ll see it written like this:

1 <?php

2 foreach($x = 1; $x <= 10; $x++) {

3 echo $x, '<br>';

4 }

Advanced stuff! If a line of code is particularly long, it’ll be shown with a \ (backslash) to notify of a line break. Don’t mistake these for actual backslashes within the code. Although of course, you may occasionally find backslashes in code. Just watch out!

1 <?php

2 echo 'Did you know that the sentence "The quick brown fox jumps over the lazy dog\

3 " contains all letters of the English alphabet? Wow!';

Other notations exist such as warnings, tips, information and recommended exercises. These are obvious so I won’t waste valuable space listing them out here.