Acknowledgments |
|
xvii | |
Introduction |
|
xix | |
|
|
|
Lesson 1 Introduction to PHP |
|
|
3 | (8) |
|
|
3 | (1) |
|
|
4 | (1) |
|
|
5 | (1) |
|
Downloading and Installing Web Browsers |
|
|
5 | (1) |
|
Choosing a Program Editor |
|
|
6 | (1) |
|
|
7 | (2) |
|
|
9 | (1) |
|
|
9 | (2) |
|
Lesson 2 Incorporating PHP into a Web Page |
|
|
11 | (6) |
|
Where to Place the PHP Code |
|
|
11 | (1) |
|
|
12 | (1) |
|
|
12 | (1) |
|
|
12 | (3) |
|
|
15 | (1) |
|
|
15 | (1) |
|
|
16 | (1) |
|
|
16 | (1) |
|
Lesson 3 Learning PHP Language Syntax |
|
|
17 | (8) |
|
|
17 | (1) |
|
|
18 | (1) |
|
|
18 | (1) |
|
|
19 | (1) |
|
|
19 | (1) |
|
Using Quotation Marks in Strings |
|
|
20 | (1) |
|
|
21 | (1) |
|
|
22 | (1) |
|
Embedding Variables within a String |
|
|
22 | (1) |
|
Variable Typing and Casting |
|
|
23 | (1) |
|
|
24 | (1) |
|
|
24 | (1) |
|
Lesson 4 Using Constants and Superglobals |
|
|
25 | (8) |
|
|
25 | (1) |
|
|
26 | (1) |
|
The echo and print Commands |
|
|
27 | (1) |
|
|
27 | (1) |
|
Superglobals and Security |
|
|
28 | (1) |
|
|
29 | (1) |
|
|
30 | (1) |
|
|
30 | (3) |
|
Lesson 5 Working with Arithmetic Operators |
|
|
33 | (8) |
|
|
33 | (2) |
|
|
35 | (1) |
|
|
35 | (1) |
|
Incrementing and Decrementing Variables |
|
|
35 | (1) |
|
|
36 | (1) |
|
|
36 | (1) |
|
Pre- and Post-Decrementing |
|
|
37 | (1) |
|
|
38 | (1) |
|
|
39 | (1) |
|
|
40 | (1) |
|
|
40 | (1) |
|
Lesson 6 Applying Comparison and Logical Operators |
|
|
41 | (10) |
|
|
41 | (2) |
|
|
43 | (2) |
|
|
45 | (1) |
|
|
45 | (1) |
|
|
46 | (1) |
|
|
46 | (1) |
|
|
46 | (2) |
|
|
48 | (1) |
|
|
49 | (1) |
|
|
49 | (2) |
|
|
51 | (8) |
|
|
52 | (1) |
|
|
52 | (1) |
|
Assigning Values to an Array Element |
|
|
52 | (1) |
|
|
53 | (1) |
|
|
53 | (1) |
|
Using Array Elements as Indexes |
|
|
54 | (1) |
|
Other Ways of Creating Arrays |
|
|
55 | (1) |
|
|
55 | (1) |
|
Keys, Values, and Hash Tables |
|
|
56 | (1) |
|
Other Ways of Creating an Associative Array |
|
|
56 | (1) |
|
|
57 | (1) |
|
|
58 | (1) |
|
Lesson 8 Managing Multidimensional Arrays |
|
|
59 | (12) |
|
Creating a Two-Dimensional Array |
|
|
60 | (2) |
|
Accessing a Two-Dimensional Array |
|
|
62 | (2) |
|
|
64 | (2) |
|
Multidimensional Associative Arrays |
|
|
66 | (1) |
|
Creating the Multidimensional Array |
|
|
67 | (2) |
|
|
69 | (1) |
|
|
69 | (1) |
|
|
70 | (1) |
|
Lesson 9 Calling Array Functions |
|
|
71 | (12) |
|
|
71 | (2) |
|
|
73 | (1) |
|
|
74 | (1) |
|
The array_walk () Function |
|
|
75 | (1) |
|
|
76 | (1) |
|
|
77 | (1) |
|
Using array_push () and array_pop () Together |
|
|
78 | (2) |
|
|
80 | (1) |
|
The array_flip () Function |
|
|
81 | (1) |
|
|
82 | (1) |
|
|
82 | (1) |
|
Lesson 10 Advanced Array Manipulation |
|
|
83 | (10) |
|
Using FILO and FIFO Arrays |
|
|
83 | (1) |
|
|
84 | (1) |
|
Using array_unshift () and array_shift () |
|
|
85 | (1) |
|
|
85 | (1) |
|
|
86 | (1) |
|
|
87 | (1) |
|
Removing Elements from an Array |
|
|
87 | (1) |
|
Inserting Elements into an Array |
|
|
88 | (1) |
|
|
89 | (1) |
|
|
90 | (1) |
|
|
91 | (2) |
|
Lesson 11 Controlling Program Flow |
|
|
93 | (12) |
|
|
93 | (1) |
|
|
94 | (1) |
|
|
95 | (1) |
|
|
95 | (2) |
|
|
97 | (1) |
|
|
98 | (2) |
|
|
100 | (1) |
|
Using the default Keyword |
|
|
100 | (1) |
|
|
101 | (1) |
|
|
102 | (1) |
|
|
102 | (3) |
|
Lesson 12 Looping Sections of Code |
|
|
105 | (14) |
|
|
105 | (1) |
|
|
106 | (1) |
|
Using do ... while () Loops |
|
|
107 | (1) |
|
|
108 | (1) |
|
|
109 | (1) |
|
|
109 | (2) |
|
|
111 | (1) |
|
Breaking Out of Multiple Loops |
|
|
112 | (1) |
|
|
112 | (1) |
|
Continuing within Multiple Loops |
|
|
113 | (1) |
|
|
114 | (1) |
|
|
115 | (4) |
|
|
|
Lesson 13 Writing Functions |
|
|
119 | (12) |
|
|
119 | (1) |
|
|
120 | (1) |
|
|
120 | (1) |
|
|
121 | (1) |
|
Handling Unknown Numbers of Arguments |
|
|
122 | (2) |
|
Global and Local Variable Scope |
|
|
124 | (1) |
|
|
124 | (3) |
|
The GLOBALS [ ] Superglobal Array |
|
|
127 | (2) |
|
|
129 | (1) |
|
|
129 | (1) |
|
|
129 | (2) |
|
Lesson 14 Manipulating Objects |
|
|
131 | (14) |
|
|
132 | (1) |
|
|
132 | (1) |
|
|
133 | (1) |
|
Accessing Properties and Objects |
|
|
133 | (1) |
|
|
134 | (1) |
|
|
135 | (1) |
|
|
135 | (1) |
|
Static Methods and Properties |
|
|
136 | (1) |
|
|
137 | (1) |
|
|
137 | (1) |
|
Property and Method Scope |
|
|
137 | (2) |
|
|
139 | (1) |
|
|
140 | (1) |
|
Writing Subclass Constructors |
|
|
141 | (1) |
|
|
142 | (1) |
|
|
142 | (1) |
|
|
143 | (2) |
|
Lesson 15 Handling Errors and Expressions |
|
|
145 | (12) |
|
|
145 | (2) |
|
|
147 | (1) |
|
|
147 | (2) |
|
|
149 | (1) |
|
|
150 | (2) |
|
|
152 | (1) |
|
|
152 | (1) |
|
|
153 | (2) |
|
|
155 | (1) |
|
|
155 | (2) |
|
Lesson 16 Building Web Forms |
|
|
157 | (12) |
|
|
157 | (2) |
|
The Difference Between Post and Get Requests |
|
|
159 | (1) |
|
Security Issues with Get Requests |
|
|
159 | (1) |
|
Accessing Form Data from PHP |
|
|
160 | (1) |
|
|
161 | (1) |
|
|
162 | (1) |
|
The checkbox and select multiple Input Types |
|
|
163 | (3) |
|
|
166 | (1) |
|
|
166 | (1) |
|
|
166 | (3) |
|
Lesson 17 Maintaining Security |
|
|
169 | (8) |
|
|
169 | (2) |
|
Uploading Files to a Server |
|
|
171 | (1) |
|
|
172 | (1) |
|
|
173 | (1) |
|
Other Potential Insecurities |
|
|
174 | (1) |
|
|
175 | (1) |
|
|
175 | (2) |
|
Lesson 18 Accessing Cookies and Files |
|
|
177 | (12) |
|
|
177 | (1) |
|
|
178 | (1) |
|
|
179 | (1) |
|
|
179 | (1) |
|
Combining These Three Functions |
|
|
180 | (1) |
|
|
181 | (1) |
|
The GetBrowser () Function |
|
|
182 | (1) |
|
|
183 | (1) |
|
Testing for a File Existing |
|
|
184 | (1) |
|
Creating or Opening a File |
|
|
185 | (1) |
|
|
185 | (1) |
|
|
186 | (1) |
|
|
186 | (1) |
|
|
187 | (1) |
|
|
188 | (1) |
|
Lesson 19 Advanced File Handling |
|
|
189 | (18) |
|
|
189 | (2) |
|
|
191 | (1) |
|
Reading from the Data File |
|
|
192 | (1) |
|
Prepopulating the Shopping List |
|
|
193 | (1) |
|
|
193 | (1) |
|
Even Simpler File Accessing |
|
|
194 | (3) |
|
|
197 | (1) |
|
|
197 | (1) |
|
|
197 | (1) |
|
|
198 | (1) |
|
Writing to a Random Access File |
|
|
199 | (1) |
|
|
199 | (1) |
|
|
200 | (1) |
|
|
201 | (4) |
|
|
205 | (1) |
|
|
205 | (2) |
|
Lesson 20 Authentication, Sessions, and Ajax |
|
|
207 | (16) |
|
|
207 | (3) |
|
|
210 | (1) |
|
Retrieving Session Variables |
|
|
210 | (1) |
|
Combining Authentication with Sessions |
|
|
211 | (1) |
|
Picking Up Session Details |
|
|
211 | (2) |
|
|
213 | (1) |
|
|
213 | (1) |
|
|
214 | (1) |
|
|
215 | (2) |
|
The PostAjaxRequest () Function |
|
|
217 | (1) |
|
The GetAjaxRequest () Function |
|
|
218 | (1) |
|
|
219 | (1) |
|
|
219 | (2) |
|
|
221 | (1) |
|
|
222 | (1) |
|
APPENDIX Answers to the Self-Test Questions |
|
|
223 | (18) |
|
|
223 | (1) |
|
|
224 | (1) |
|
|
225 | (1) |
|
|
226 | (1) |
|
|
226 | (1) |
|
|
227 | (1) |
|
|
228 | (1) |
|
|
229 | (1) |
|
|
230 | (1) |
|
|
231 | (1) |
|
|
231 | (1) |
|
|
232 | (1) |
|
|
233 | (1) |
|
|
234 | (1) |
|
|
235 | (1) |
|
|
236 | (1) |
|
|
237 | (1) |
|
|
238 | (1) |
|
|
239 | (1) |
|
|
240 | (1) |
Index |
|
241 | |