John M. Astell ♦ Portfolio

PHP Bare-Bones Tutorials

These are bare-bones PHP tutorials that will get you up to speed with PHP quickly. "Bare-bones" means they don't explain common programming concepts like variables, arrays, functions, classes, etc. If you are familiar with almost any other programming or scripting language, you already know these concepts. If you don't have clue about this stuff, go get some grounding first. You can easily look it up. This principle also applies to various mundane details of PHP itself. The tutorials will cover variables in details, but you can easily look up which characters are allowed for PHP variable names. The tutorials cover important PHP operator precedence and associativity topics, but the complete list of operators, precedence levels, and associativity rules is something you can easily look up: you can always start with the PHP Manual itself (it's online and likely also in your PHP installation).

These tutorials also do not go into administrative aspects like how to set up PHP (hint: get access to a server with PHP on it) or configure it (hint: the default configuration is usually sufficient to get you started).

These tutorials do expect you to examine their PHP source code as you go along, and each page includes a link to open the source code in a separate tab or window. If you have a web server with PHP running, feel free to cut and paste the source code and experiment with it for personal use only.

These tutorials typically use simple, direct, brute-force PHP coding techniques, because they work and are easy to understand. In particular, many variables are global and some statements are in the global scope. While this works fine for short PHP scripts and for the tutorials, too much global use can cause problems in more complicated programs. See the final comments of Tutorial 1 for more about this.

PHP Tutorial 1 (Basic Level)

PHP Tutorial 1 is a crash course to get you able to code basic-level PHP scripts. It covers these topics:

Master this, and you can use PHP to create interactive web pages where you can get input from your users, process it on your server, and serve up updated or new pages based on the processing.

PHP Tutorial 2 (Intermediate Level)

PHP Tutorial 2 covers variables in greater depth:

The sections on variable variables (dynamic variables) and variable references go beyond what most tutorials cover. You'll learn not just how to use them, but important tips, gotchas, and behind-the-scenes looks about them. You'll find out that $$var1 looks like a variable with an extra $ and is used like one, but it really isn't a variable (check out the Extra Credit section of Variable Variables 1). You'll discover the use and misuse of references, including what works and what fails when passing returned references to other functions (see Variable References 8, Passing Returned References).

PHP Tutorial 3 (Intermediate Level)

PHP Tutorial 3 covers these topics in greater depth:

Oh? You want some promo text telling how great this tutorial is? OK, PHP sometimes works a little different than other languages you might be more familiar with, and sometimes a lot more, including C/C++, Java, JavaScript, and Perl. The initial tutorials here cover important aspects of these differences, so that you can do things the PHP way and end up with code that does what you want it to.

The Sets of Logical Operators Tutorial covers the two different sets of operators PHP uses for logical AND, logical OR, logical NOT, and logical XOR. Why two sets? Check out the tutorial! Interestingly, each set is missing one operator (fortunately not the same one), and the tutorial covers how you can get the effect of the missing operator by using the other operators in the set.

The next three tutorials cover important dynamic aspects of PHP: variable functions and variable arrays. If you loved/hated variable variables in PHP Tutorial 2, your love/hate relationship will be enhanced with these!

The last set of tutorials covers how to use PHP anonymous functions (aka lambda functions) and closures. They cover how to know the difference between the two (all PHP closures are anonymous functions, but only some PHP anonymous functions are closures) and which is appropriate to use (including thrilling mentions of "early binding" and "late binding").