[Content Overview]
This book combines PHP development with MySQL applications and analyzes PHP and MySQL separately. It not only introduces the general concepts of PHP and MySQL, it also gives a comprehensive description of PHP and MySQL Web applications, including several classic and practical examples.
This book is version 4th and has been fully updated, rewritten, and expanded, including the latest improved features of PHP 5.3 (for example, better error and Exception Handling ), mySQL stored procedures and storage engines, Ajax technology and Web 2.0, and Web applications need to pay attention to security issues.
[Author's profile]
Laura Thomson is a senior software engineer at Mozilla. Previously, she was a partner at OmniTI and Tangled Web Design. In addition, Laura has worked at the University of RMIT and the Boston Consultancy Group. She earned a bachelor's degree in Application Science (computer science) and a bachelor's degree in engineering (Computer System Engineering. During her free time, she enjoyed riding, discussing free software and open source software, and sleeping.
Luke Welling is a Web architect at OmniTI. He often works at international conferences (such as OSCON, ZendCon, MySQLUC, HPCon, OSDC, and LinuxTag) open source and Web development topics. Before joining OmniTI, he worked for Hitwise.com as a Web analyst at a database provider. He is also an independent consultant at Tangled Web Design. He also teaches Computer Science at the University of RMIT in Melbourne, Australia. He earned a bachelor's degree in Applied Science (computer science. In his free time, he hopes to cure his insomnia.
[Directory]
Reader feedback
Translator's preface
Preface
Author Profile
Article 1 Use PHP
Chapter 1 PHP quick start tutorial 1
Before 1.1: Understand PHP
1.2 create an example application: Bob auto parts store 2
1.2.1 create order form 2
1.2.2 form processing 4
1.3 embed PHP 4 in HTML
1.3.1 Use PHP to mark 5
1.3.2 PHP Statement 6
1.3.3 space 6
1.3.4 Note 7
1.4 Add dynamic content 8
1.4.1 call function 8
1.4.2 use date () function 9
1.5 access form variable 9
1.5.1 short, medium, and long form variable 9
1.5.2 string connection 11
1.5.3 variables and text 12
1.6 understanding identifier 13
1.7 check variable type 13
1.7.1 PHP Data Type
1.7.2 type strength
1.7.3 type conversion
1.7.4 variable
1.8 declaration and use constant 13
1.9 understand the scope of the variable 13
1.10 use operator 16
1.10.1 Arithmetic Operator 17
1.10.2 string operator 17
1.10.3 value assignment operator 17
1.10.4 comparison operator 19
1.10.5 logical operator 20
1.10.6-bit operator 21
1.10.7 other operators 21
1.11 calculate the total form amount 23
1.12 understanding of the priority and associativity of operators:
1.13 use variable functions 25
1.13.1 test and set variable type 26
1.13.2 test variable status 26
1.13.3 variable re-interpretation 27
1.14 making decisions based on conditions 27
1.14.1 if statement 28
1.14.2 code block 28
1.14.3 else statement 28
1.14.4 elseif statement 29
1.14.5 switch statement 30
1.14.6 compare different conditions 31
1.15 repeated action through iteration 32
1.15.1 while LOOP 33
1.15.2 for and foreach loop 34
1.15.3 do... while loop 35
1.16 jump out of the control structure or script 35
1.17 use replaceable control structure syntax 36
1.18 declare 36
1.19 chapter 37
Chapter 3 data storage and retrieval 38
2.1 save data for later use
2.2 store and retrieve Bob's Order 38
2.3 File Processing 39
2.4 open a file 40
2.4.1 select file mode 40
2.4.2 use fopen () to open a file 40
2.4.3 open a file through FTP or HTTP 42
2.4.4 solve problems that may occur when opening a file 42
2.5 write files 44
2.5.1 fwrite () parameter 44
2.5.2 file format 45
2.6 close file 45
2.7 read files 47
2.7.1 open a file in read-only mode: fopen () 48
2.7.2 know when to read the file: feof () 48
2.7.3 each time a row of data is read: fgets (), fgetss (), and fgetcsv () 49
2.7.4 read the entire file: readfile (), fpassthru (), and file () 49
2.7.5 read one character: fgetc () 50
2.7.6 read arbitrary length: fread () 51
2.8 use other useful file functions 51
2.8.1 check whether the file exists: file_exists () 51
2.8.2 determine the file size: filesize () 51
2.8.3 delete an object: unlink () 51
2.8.4 locate in the file: rewind (), fseek (), and ftell () 52
2.9 file lock 52
2.10 better way: Database Management System 53
2.10.1 Common File Usage 54
2.10.2 how RDBMS solves these problems 54
2.11 further study 54
2.12 next chapter 55
Chapter 1 use arrays 56
3.1 What is array 56
3.2 numeric index array 57
3.2.1 numeric index array initialization 57
3.2.2 access to array content 57
3.2.3 Use loop access array 58
3.3 using arrays with different indexes 59
3.3.1 initialize related arrays 59
3.3.2 access array element 59
3.3.3 Use loop statement 59
3.4 array operator 60
3.5 multi-dimensional array 61
3.6 array sorting 64
3.6.1 use the sort () function 64
3.6.2 use the asort () function and ksort () function to sort related arrays 64
3.6.3 reverse sorting 65
3.7 multi-dimensional array sorting 65
3.7.1 User-Defined sorting 65
3.7.2 reverse user sorting 66
3.8 re-sort the array 67
3.8.1 use shuffle () function 67
3.8.2 Use the array_reverse () function 68
3.9 load an array from a file 69
3.10 perform other Array Operations 71
3.10.1 browsing in the array: each (), current (), reset (), end (), next (), pos (), and prev () 71
3.10.2 apply any function to each element of the array: array_walk () 72
3.10.3 count the number of array elements: count (), sizeof (), and array_count_values () 73
3.10.4 convert an array to a scalar variable: extract () 73
3.11 Further Study 75
3.12 next chapter 75
Chapter 2 string operations and regular expressions 76
4.1 create an example application: smart form mail 76
4.2 string formatting 78
4.2.1 string sorting: chop (), ltrim (), and trim () 78
4.2.2 format the string to display 78
4.2.3 format the string for storage: addslashes () and stripslashes () 81
4.3 Use string functions to connect and split strings 82
4.3.1 use functions explode (), implode (), and join () 82
4.3.2 Use strtok () function 83
4.3.3 use substr () function 83
4.4 string comparison 84
4.4.1 sort strings: strcmp (), strcasecmp (), and strnatcmp () 84
4.4.2 use the strlen () function to test the string length of 85
4.5 Use string functions to match and replace substrings 85
4.5.1 search for strings: strstr (), strchr (), strrchr (), and stristr () 85
4.5.2 locate the substring: strpos (), strrpos () 86
4.5.3 replace substring: str_replace (), substr_replace () 87
4.6 introduction to regular expressions 88
4.6.1 basic knowledge 88
4.6.2 Character Set and class 88
4.6.3 repeated 89
4.6.4 subexpression 89
4.6.5 subexpression count 90
4.6.6 locate the start or end 90 of the string
4.6.7 branch 90
4.6.8 match special characters 90
4.6.9 Special Character List 91
4.6.10 apply 91 in smart forms
4.7 use a regular expression to search for a substring 92
4.8 use regular expression to split string 93
4.9 comparing string functions and regular expression functions 93
4.10 further study 93
4.11 Chapter 93
Chapter 4 code reuse and function writing 94
5.1 benefits of code reuse
5.1.1 cost 94
5.1.2 reliability 94
5.1.3 consistency 95
5.2 use the require () and include () functions 95
5.2.1 file extension and require () Statement 96
5.2.2 use require () to create a Web site template 96
5.2.3 use auto_prepend_file and auto_append_file 101
5.3 use function 101 in PHP
5.3.1 call function 101
5.3.2 call undefined function 103
5.3.3 understand uppercase/lowercase letters and function names 103
5.4 understand why define your own function 103
5.5 understand basic function structures 104
5.5.1 function naming
5.6 use parameter 105
5.7 understanding scope 107
5.8 parameter reference transfer and value transfer 109
5.9 use the Return keyword 110
5.9.1 return a value of 111 from the function
5.10 implement recursion 113
5.10.1 namespace
5.11 further study 114
5.12 next chapter 114
Chapter 2 object-oriented PHP 6th
6.1 understand object-oriented concepts 115
6.1.1 class and object 115
6.1.2 polymorphism 116
6.1.3 inherit 117
6.2 create classes, properties, and operations in PHP 117
6.2.1 class structure 117
6.2.2 constructor 118
6.2.3 destructor 118
6.3 class instantiation 118
6.4 Use class attributes 119
6.5 use private and public keywords to control access 121
6.6 class operation calls 121
6.7 implement inheritance in PHP 122
6.7.1 use private and protected access modifiers to control visibility 123 through inheritance
6.7.2 heavy load 124
6.7.3 use the final keyword to prohibit inheritance and overloading 125
6.7.4 understand multi-inheritance 126
6.7.5 implement interface 126
6.8 class design 127
6.9 write class code 128
6.10 understand PHP object-oriented new advanced functions 135
6.10.1 use the Per-Class constant 135.
6.10.2 static method 135
6.10.3 check the class type and type prompt 136
6.10.4 clone object 136
6.10.5 use an abstract class 137
6.10.6 use the _ call () overload method 137
6.10.7 use the _ autoload () method 138
6.10.8 implement iterator and iteration 138
6.10.9 convert a class to a string 140
6.10.10 use Reflection (Reflection) API 140
6.11 next Chapter 141
Chapter 4 error and Exception Handling 7th
7.1 concept of exception handling 142
7.2 Exception class 144
7.3 user-defined exceptions 144
7.4 Bob's auto parts store app exception 146
7.5 exception handling and other PHP error handling mechanisms 150
7.6 further study 150
7.7 next chapter 150
Article 2 using MySQL
Chapter 2 Design Web Database 8th
8.1 concept of relational database 152
8.1.1 table 152
Column 8.1.2 152
8.1.3 row 152
8.1.4 value 152
8.1.5 key 152
8.1.6 mode 153
8.1.7 relationship 153
8.2 how to design Web Database 154
8.2.1 consider the actual object to be modeled 154
8.2.2 avoid saving redundant data 154
8.2.3 use the atomic column value 155
8.2.4 select meaningful key 156
8.2.5 questions about the database 156
8.2.6 avoid designing multiple null attributes 156
8.2.7 summary 157
8.3 Web database architecture 157
8.4 further study 158
8.5 next chapter 158
Chapter 4 creating a Web Database 9th
9.1 use the MySQL monitoring program 160
9.2 log on to MySQL 160
9.3 create databases and users 161
9.4 set users and permissions 162
9.5 MySQL permission system Introduction 162
9.5.1 minimum permission principle 162
9.5.2 create a user: GRANT command 162
9.5.3 permission type and level 163
9.5.4 REVOKE command 165
9.5.5 example of using GRANT and REVOKE 165
9.6 create a Web user 166
9.7 use the correct database 166
9.8 create a database table 167
9.8.1 understand the meaning of other keywords 168
9.8.2 understanding the column type 169
9.8.3 use SHOW and DESCRIBE to view database 170
9.8.4 create an index 171
9.9 understand the MySQL identifier 171
9.10 Select column data type 172
9.10.1 numeric 173
9.10.2 Date and Time type 174
9.10.3 string 174
9.11 further study 176
9.12 next Chapter 176
Chapter 4 use MySQL database 10th
10.1 what is SQL 177
10.2 insert data into the database 177
10.3 obtain data from the database 179
10.3.1 obtain data that meets specific conditions 181
10.3.2 obtain data from multiple tables 182
10.3.3 obtain data in a specific order: 186
10.3.4 grouping and total data: 186
10.3.5 select row 188 to return
10.3.6 use subquery 188
10.4 update database records 190
10.5 Modify Table 191 After creation
10.6 delete records in the database 193
10.7 delete a table 193
10.8 Delete the entire database 193
10.9 further study 194
10.10 next Chapter 194
Chapter 4 Access MySQL database from the Web using PHP 11th
11.1 working principles of Web database architecture 195
11.2 basic steps for querying databases from the Web 198
11.2.1 check and filter user input 198
11.2.2 establish a connection 199
11.2.3 select database 200
11.2.4 query database 200
11.2.5 query result 201
11.2.6 disconnect from database 202
11.3 add new information to the database 202
11.4 use Prepared statement 205
11.5 use other interfaces for PHP interaction with the database 206
11.5.1 use the regular database interface PEAR MDB2 206
11.6 further study 209
11.7 next chapter 209
Chapter 2 MySQL advanced management 12th
12.1 deep understanding of permission system 210
12.1.1 user table 211
12.1.2 db and host tables 212
12.1.3 tables_priv table, columns_priv table, and procs_priv table 212
12.1.4 Access Control: how to use Grant table 213 in MySQL
12.1.5 update permission: When does the modification take effect? 213
12.2 improve MySQL database security 214
12.2.1 protecting MySQL 214 from the Operating System
12.2.2 password 214
12.2.3 user permission 215
12.2.4 Web problems 215
12.3 obtain