Hi, and welcome to PHP: From Beginner to Pro. My name is Theodore and I would like to help you master PHP and coding in general.

I am sure you have a lot of questions, so let’s begin with the fundamentals.

What is Programming?

The creator of the PERL language explains: Programming Explained in 5 Minutes.

What is PHP?

PHP is a full-fledged programming language specialized in creating dynamic web applications. PHP orchestrates the gathering of the data it needs, manipulates it to achieve results, and presents it to the end-user, typically by generating XHTML that is then passed onto a web server which passes the XHTML and other static content to the end-user in the form of a web page. However, PHP is not limited to the web. With PHP, you can build practically any type of program, including standalone Windows programs or apps that will run on embedded hardware.

Technically, PHP is a popular open source, loosely dynamically-typed, object-oriented, interpreted programming language.

  • Popular: As of July 2010, PHP was available on approximately 25 million domain names. This is compared to ASP.NET servers: 900,000; and Java: 70,000 .
  • Open source: You can, if you want, freely look at, copy, and modify the source code of PHP. This means that no matter what, PHP will always be available and maintained by the community if nothing else.
  • Loose dynamically-typed: Unlike most languages, variable’s types in PHP are not manually defined, something you’ll come to appreciate a lot in the near future.
  • Object-oriented: PHP can be used in both a procedural and object oriented way, unlike most modern languages which force a methodology on you.
  • Interpreted: PHP code is not compiled but runs “just in time”.

Why learn PHP?

There are so many languages to learn, and PHP jobs in 2010 are only a fraction of the total out there. So why learn it over other languages with seemingly more job opportunities at present?

PHP is one of the most versatile programming languages on the planet. With it, you can not only build a personal web page, but also complex web applications, automate system tasks, and even traditional Windows applications. There are three major distinctions between PHP and most mainstream languages:

  1. Using PHP is absolutely free — PHP itself is free and open source and there are no dependencies on costly web servers, databases or operating systems.
  2. There is no forced way to do things — Unlike virtually all other high-level languages, PHP gives you the flexibility to use what you want when you need to and doesn’t force some ideological “correct” way on to everyone.
  3. PHP applications do not have a separate “build” process — PHP code is run directly; no wasted time compiling it. It’s “just in time” execution done right.

Compared to most languages, PHP also has far more freely available and included by default functions and extensions than practically any other language. It has been estimated that if one were to try to map just the 80% most used functions to the ASP.NET platform, the expenses would run well into the thousands of dollars, as many of those features would have to be purchased from 3rd party vendors. And while a typical PHP server just factors in the hardware and operational costs, Java and ASP.NET servers can cost thousands, just in license fees.

But aren’t there more jobs for Java and ASP.NET than PHP? What good is PHP if there are no jobs?

It’s true; in absolute terms, on a whole, Java and ASP.NET have more jobs out there, but looks can be deceiving. For starters, the average base pay for professional coders tends to be higher for PHP than the other two. Secondly, because of the recession, ASP.NET and Java are quickly losing ground to PHP. The number of Java jobs has dropped almost a fifty percent since 2009, ASP.net jobs now more or less equal PHP jobs, after more than doubling them in mid-2007.

Secondly, the adoption of PHP in the workforce is accelerating at three times the rate of ASP.NET and Java combined.

Yes, the future looks bright for professional PHP programmers.

What does it take to become a PHP expert?

There are four fundamental themes you must master to become a PHP expert:

  1. Firm knowledge of the fundamentals of the language (e.g. what are variables? functions? classes? OOP? etc.)
  2. A solid grasp of the functionality PHP comes with built-in,
  3. Sound programming methodologies for both common and not-so-common problem sets,
  4. Continuous education: PHP and programming in general are constantly evolving, so make sure you are, too.

How does this book differ?

This is not your typical programming book.

You know? The one you read twenty pages of then skipped a few hundred and read 5 more? This book aims to be engaging, direct, and limited in the extraneous stuff you just don’t need to know or can research for yourself. It is meant to be read from cover to cover.

There is minimal hand holding.

Every programming book I’ve ever read tries to laboriously explain every bit of code before you’re introduced to it. So of course, all of the really interesting stuff is handled at the very end, if at all. Now if you’ve ever read one of those 600 page monstrosities, this will come as a shock. Especially to the absolute beginners among us, I encourage you to view this book like you would if you were in a foreign country where no one spoke your language: Just try to understand what is being taught and save the other questions for later.

This book is more fun.

Our first application is a form handler! Within a few pages, we’re creating a basic blog. Chapter 5: AJAX. A lot of that fun stuff you’ve been hearing about, we’ll cover in one way or another. The idea is that when you get asked, “Do you know AJAX?”, you’ll be able to say, “yes!”. Can you build an MVC? “Yes!” Can you build a blog in a day? “Sure!” Don’t know what any of this means? This book is for you!

This book is easier to read.

Face it. Who wants to pour over a huge book with small text and tight paragraphs? So instead, let’s focus more on code by example and leave the reference material to … reference websites.

This book is interactive.

It is full of do-it-yourself exercises and many accompanying Youtube videos.

What inspired this book?

If it isn’t evident by now, I am a PHP evangelist of sorts. I’ve coded in C++, ASP.NET, Python, Java, Perl, PHP, Visual Basic, C++, heck, most of the languages, and yet I love PHP. I know all of the arguments for and against it, and believe me, the pros far outweigh the cons, more so than most languages. Almost all of the negative sentiment stems from either PHP being irrational in function naming (this is true, but it’s the same with English, you just have to memorize, learn how to use a dictionary and move on) and perceived lack of coder prowess in general.

The aims of this book are to

  • Teach you correctly from the start, and to give those of you who are familiar with the language the paradigms and mindsets that separate the wheat from the chaff;
  • Prepare for you for the Zend PHP 5 certification exam; and
  • Give you the skills you need to qualify for your first solid PHP job.

So what are you waiting for? Let’s begin!