only for RuBoard - do not distribute or recompile | ![]() ![]() |
In this chapter, we introduce the PHP scripting language. PHP is similar to high-level languages such as C, Perl, Pascal, FORTRAN, and Java, and programmers who have experience with any of these languages should have little trouble learning PHP. This chapter serves as an introduction to PHP; it's not a programming guide. We assume you are already familiar with programming in a high-level language.
The topics covered in this chapter 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 chapter 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 Chapter 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.
We don't attempt to cover every function and every library that are supported by PHP. However, we provide brief descriptions of the supported libraries in Appendix E. In later chapters, we discuss more specialized library functions that support the topics and techniques presented here.
only for RuBoard - do not distribute or recompile | ![]() ![]() |