The topics covered in this tutorial include:

  • PHP basics, including script structure, variables, supported types, constants, expressions, and type conversions

  • Condition and branch statements supported by PHP, including if, if...else, and the switch statements

  • Looping statements

  • Arrays and array library functions

  • Strings and string library functions

  • Regular expressions

  • Date and time functions

  • Integer and float functions

  • How to write functions, reuse components, and determine the scope and type of variables

  • An introduction to PHP object-oriented programming support

  • Common mistakes made by programmers new to PHP, and how to solve them

Programmers new to PHP should read Section 2.1, which describes the basic structure of a PHP script and its relationship to HTML, and includes discussion of how PHP handles variables and types. The two sections that follow, Section 2.2 and Section 2.3, deal with conditional statements and looping structures and should be familiar material. We then present a short example that puts many of the basic PHP concepts together.

The remainder of the tutorial expands on the more advanced features of PHP, presents a reference to selected library functions, and discusses some of the common mistakes that programmers make when learning PHP. This material can be examined briefly, and used later as a reference while reading tutorial 4 to 13 and while programming in PHP. However, programmers new to PHP should consider reading the beginning of the Section 2.5 and Section 2.6 sections to understand the way PHP supports these concepts, as there are important differences from other languages.

These tutorials will not cover every function and every library that are supported by PHP. However, you can find brief descriptions of the supported libraries in the last tutorials. In later tutorials, we discuss more specialized library functions that support the topics and techniques presented here.