
- •Initializing with Constructor Functions . . . . .
- •Into a Web page as a separate section. Although JavaScript code can
- •Is that standard php script delimiters are guaranteed to be available
- •In the block. Any text or lines between the opening /* characters and
- •2.7541 Are not integers; they are floating-point numbers. A floating-
- •Value 300
- •Is a value of 2.5, because 6 goes into 15 exactly 2.5 times. But if you
- •IsEven.Php.
- •Ing example,
- •Ing curly brace is on its own line following the function statements.
- •In php 3 and earlier, it was necessary to put a function definition
- •Is called an iteration. When the conditional expression evaluates
- •Including Files
- •13. Close your Web browser window.
- •Including Files
- •In php, you can also use two operators to combine strings. The first
- •Xhtml source code gen-
- •Input. Php provides several functions for manipulating the case of a
- •Is uppercase. If you need the reverse of ucfirst(), the lcfirst()
- •In some situations, you will need to find and extract characters and
- •Information Interchange, or ascii, which are numeric represen-
- •In comparison, the following preg_match() function returns a value
- •In the pattern is optional. The following code demonstrates how to
- •Values; any strings you validate against a regular expression must
- •Value of 1 because the top-level domain contains a valid value of .Com.
- •Is submitted using the “post” method, the form data is embedded in
- •Validating String Data
- •Xhtml tags or character entities. The message field is a text string
- •Value of the header element. For example:
- •Xhtml code within a php script section.
- •Is typically the person who created the resource. Otherwise, the net-
- •If even a single character of the Web page is sent prior to sending
- •Variables to the file_put_contents() function.
- •Xhtml hyperlink. To download a file from outside the xhtml
- •If...Else statement to display the appropriate version of the mes-
- •Iterating Through an Array
- •Iterating Through an Array
- •In Chapter 2, you learned how to use a foreach statement to iterate
- •Iterating Through an Array
- •Iterating Through an Array
- •In comparison, the following code declares and initializes
- •If ((!file_exists("MessageBoard/messages.Txt"))
- •Values from the array to create a thumbnail gallery of images in which
- •Introduction to Databases
- •Including php, allow you to create Web pages that can read and write
- •Introduction to Databases
- •Information that can be organized into ordered sets of data, and
- •Information. Each recipe in a recipe database, for instance, is a single
- •Introduction to Databases
- •Index, which identifies records in a database to make retrievals and
- •In a single table. However, you might want to break the information
- •Into multiple tables to better organize it into logical sets. Another
- •Information in one of the tables confidential and accessible only by
- •Is the employee information table from Figure 7-1. The related table
- •Is a payroll table that contains confidential salary and compensation
- •Information. Notice that each table contains an identical number of
- •Introduction to Databases
- •Introduction to Databases
- •In a junction
- •Introduction to Databases
- •In a relational format is called a relational database management
- •Is a standard data manipulation language among many dbmSs.
- •Into the query area at the top of the screen or by dragging tables and
- •It is important to understand that even though many dbmSs sup-
- •Introduction to Databases
- •If you ever
- •Is. In comparison, the bigint data type stores integer values between
- •5 Rows in set (0.00 sec)
- •Int);[enter ]
- •Important, these two tabs can cause you to lose all of the data in the
- •Internet Explorer to export the table, click the Save button in the File
- •Ifies the table being changed and the change to make.
- •It easier for you to write php code that can be used with a variety of
- •Information about queries that match one of the following formats:
- •Various types of actions, depending on the type of query.
- •Include fields for the date and time of the flight, flight number, and
- •In the ChineseZodiac folder and upload the file to the server. Open
- •Including white space,
- •Information on a Web server. When you start a new session, the
- •Introduction to Object-Oriented Programming
- •Introduction to Object-Oriented
- •Variables associated with an object are called properties or attributes.
- •In the Loan object example, a function that calculates the number of
- •Introduction to Object-Oriented Programming
- •Introduction to Object-Oriented Programming
- •Include instances of objects inherit the object’s functionality.
- •In this chapter, you will create the Web site for an online order form
- •In an online store application. The application includes information
- •Ity of building a working online store. Online store classes are very
- •Information and products. The OnlineStore class requires that store
- •Information is stored in a table containing six fields: storeId, name,
- •Information. Instead, the class simply uses session iDs to keep track
- •Variable and function as necessary, without bothering with all this
- •In a class
- •Is developed. Imagine what would happen if Microsoft distributed
- •Ing class is invalid because it does not include an access specifier:
- •If they will not be supported by future xhtml versions or are not
- •Xhtml standards. To review the guide of current w3c css specifi-
- •Information to remind yourself or others of what the code is doing. A
- •Xhtml document to the external style sheet. This link informa-
- •If you select Apache from the WampServer menu and select Service
- •Ing code uses the number_format() function to add comma separa-
- •In data that a user submits to a php script.
- •Value of “On” and the display_startup_errors directive is assigned
- •Instead. By looking at the source code, you could see that the value of
- •Ing engine can even help locate logic errors.
- •In Chapter 8, along with the equivalent mssql_* functions, where
- •Inline styles, 632
- •Xhtml, 620–635 (continued)
INDEX
specificity,
635Inline styles, 632
input streams, 267
INSERT INTO statement, 412–414
installing
Notepad++, 622–625
Portable Apps Suite, 620–622
text editors, 620–625
xAMP, 636–638
instance(s), 560
instanceof operator, 58, 62
instantiation, 560
MySQL database objects, 566–568
(int) operator, 58, 61
integer(s), 31
(integer) operator, 58
interfaces, 559–560
internal array pointer, 323
internal style(s), 632–634
internal style sheets, specificity, 635
Internet Explorer, viewing source code,
665
is_dir() function, 243
is_executable() function, 243
is_file() function, 243
is_link() function, 243
is_readable() function, 243
isset() function, 209, 650
is_writable() function, 243
is_writeable() function, 243
iterating through arrays, 323–327
iterations, 96
less than or equal to operator (>+), 51
Levenshtein, Vladimir, 158
Levenshtein distance, 158
levenshtein() function, 158
line comments, 21
linked style sheets, 634–635
literal(s), 40
literal strings, 14
LOAD DATA statement, 414–415
local variables, 82
locking files, 272–274
logging errors to a file, 661
logging in to phpMyAdmin, 428–431
logic, analyzing, 663–664
logic errors, 656–657
logical And operator (&&), 55
logical exclusive Or operator (XOR), 55
logical Not operator (!), 55
logical operators, 54–58
logical Or operator (||), 55
loop statements, 95–109
do...while statements, 100–103
foreach statements, 105–109
for statements, 103–105
while statements, 96–100
loosely typed programming languages, 31
lowercase markup tags, XHTML, 628
686
M
magic quotes, 196–198, 653–654
mail() function, 206, 207
maintaining state, 497
many-to-many relationships, 386–388
matching characters in regular expressions,
162–164
MAX() function, 418
md5() function, 138–139
member functions, 573, 584–599
cleaning up with destructor functions,
587–588
initializing with constructor functions,
585–587
serialization functions, 594–599
$this reference, 585
writing accessor and mutator functions,
588–594
member selection notation, 564
member variables, 573
J
junction tables, 387
K
key(s), arrays, determining if a key exists,
333–334
key() function, 323, 324
keywords. See also specific keywords
SQL, 391
krsort() function, 336, 342
ksort() function, 336, 337, 342
L
LAMP, 636
less than operator (>), 51
INDEX
metacharacters,
162
metaphone()
function,
159
method(s),
OOP, 557, 582
method
attributes,
192–194
Microsoft
Internet Explorer, viewing source
code,
665
microtime() function, 258
MIME (Multipurpose Internet Mail
Extensions), 248
minus sign (-)
addition operator, 62
compound subtraction assignment
operator, 49, 62
conversion specifications, 645, 646
decrement operator, 44–48, 61
subtraction operator, 42
mkdir() function, 241–242
modifying variables, 25–27
modulus (%), 42
moving files, 278–280
Mozilla Firefox, viewing source code, 665
multidimensional arrays, 350–359
with more than two dimensions, 357–359
with single statement, 356–357
two-dimensional, associative, 355–356
two-dimensional, indexed, 351–355
multiple code declaration blocks, 17–20
multiplication operator (*), 42
Multipurpose Internet Mail Extensions
(MIME), 248
mutator functions, 588–594
MySQL, 389, 391, 392–402, 399–402
accessing with PHP. See accessing MySQL
with PHP; connecting to MySQL
with PHP; retrieving records
commands, 394–395, 396–398
creating databases, 399–400
deleting databases, 401–402
identifiers, 395–396
logging in, 392–394
MySQL Monitor, 392, 394–395
selecting databases, 400–401
user privileges, 408–412
MySQL database objects
closing, 566
errors, handling, 568–570
executing SQL statements, 570–573
instantiating, 566–568
MySQL tables, 459–463
creating, 460–463
deleting, 463
mysql_affected_rows() function, 470–471
mysql_change_user() function, 449
mysql_create_db() function, 453–454
mysql_data_seek() function, 474
mysql_drop_db() function, 458
mysql_errno() function, 451–452
mysql_error() function, 451–452
mysql_fetch_array() function, 474
mysql_fetch_assoc() function, 474,
687
477–478
mysql_fetch_lengths() function, 474
mysql_fetch_row() function, 474–476
mysql_free_result() function, 479
mysql_get_client_info() function, 449
mysql_get_client_version() function,
449
mysql_get_host_info() function, 449
mysql_get_proto_info() function, 449
mysql_get_server_info() function, 449
mysqli_connect_errno() function, 452
mysqli_connect_error() function, 452
mysql_info() function, 471–473
mysql_num_fields() function, 480–481
mysql_num_rows() function, 460
mysql_query() function, 459–460, 464, 473,
479
mysql_select_db() function, 455–457
mysquli package, 448
N
name argument, cookies, 519–521
naming. See also renaming
counters, 96
files, 3, 651, 652
variables, 23
natcasesort() function, 336, 337
natsort() function, 336, 337
navigating within Web page templates, 214
nested decision-making structures, 89–92
nested tags, XHTML, 628–629
attributes, 629
new clone, associativity, 61
next() function, 323, 325
normalization, 384
not equal operator (!= or <>), 51
INDEX
notation
avoiding
pitfalls, 40
exponential, 31
member selection, 564
scientific, 31
Notepad++, installing, 622–625
notice messages, 658
NULL value, 30
number(s)
decimal, specifying precision, 643–644
formatting, 645–646
number_format() function, 645–646
numeric data, validating, 199–200
numeric data type, 31–32
operands, 40
operator(s), 40–41
arithmetic, 41–48
assignment, 48–51
associativity, 61–63
binary, 41, 42–44
comparison, 51–52, 53–55
conditional, 52–55
logical, 54–58
postfix, 44–48
prefix, 44–48
special, 58
unary, 41, 44–48
operator precedence, 61–63
OR operator, 55, 62
Oracle, 674–677
ord() function, 154
order by keyword, 421
output steams, 267
688
O
object(s), 557
database connections as objects, 565–573
MySQL database objects. See MySQL
database objects
using in PHP scripts, 563–578
(object) operator, 58, 61
object-oriented PHP
declaring data members, 578–583
member functions. See member functions
objects, 563–578
object-oriented programming (OOP),
557–563
classes, 560–563
encapsulation, 559–560
PHP. See object-oriented PHP
observer functions, 588–594
ODBC (Open Database Connectivity), 390,
447
one-to-many relationships, 384–386
one-to-one relationships, 383–384
one-way hashes, 138–139
OOP. See object-oriented PHP; object-
oriented programming (OOP)
Open Database Connectivity (ODBC), 390,
447
opendir() function, 238
opening
file streams, 267–269
MySQL connections, 448–451
opening delimiters, regular expressions,
161
opening tags, XHTML, 628
P
padding, specifying, 644–645
parameters (formal parameters), 75–76
passing by reference, 80–81
passing by value, 80
parent table, 382
parse error(s), 655–656
parse error messages, 657–658
parsing strings, 141
passing arguments, 11
path argument, cookies, 525
pattern modifiers, 169–170
PCRE. See Perl Compatible Regular
Expressions (PCRE)
percent sign (%)
compound modulus assignment operator,
49
conversion specifications, 641
modulus, 42
period (.). See dot (.)
Perl Compatible Regular Expressions (PCRE)
delimiters, 160
escape sequences, 168
quantifiers, 164
persistent cookies, 518
PHP
object-oriented. See object-oriented PHP
ODBC, 447
INDEX
PHP
script(s), 2–3
code
declaration blocks. See code
declaration blocks
comments, 20–22
cookie interference, 521
delimiters. See PHP script delimiters
displaying results, 12–16
filename extensions, 3
statements, 3–4
PHP script delimiters, 3–5
ASP-style, 9–10
phpinfo() function, 190, 196, 448
php.ini file, 530
changing settings in, 653
phpMyAdmin, 428–433
databases, 431–432
logging in, 428–431
tables, 432–433
phpversion() function, 18
pipe (|), logical Or operator, 55, 62
plus sign (+)
addition operator, 42, 62
compound addition assignment operator,
49, 62
conversion specifications, 645
increment operator, 44–48, 61
quantifier, 164
Portable Apps Suite, installing, 620–622
postfix operators, 44–48
PostgreSQL, 389
pound symbol (#), comments, 21
predefined constants, 29
prefix operators, 44–48
preg_grep() function, 160
preg_match() function, 160
preg_quote() function, 160
preg_replace() function, 160
preg_split() function, 160
prev() function, 323
primary array, 343
primary key, 383
primary table, 382
primitive data type, 30
print() function, 564
print statement, 13
print_errors directive, 659
printf() function. See formatting strings
print_r() function, 662
print_startup_errors directive, 659
private access specifier, 580
privileges, MySQL, 408–412
definition, 408
granting, 409–411
revoking, 411–412
processing
All-in-One forms, 210
form data, 194–198
programming language(s)
loosely typed, 31
strongly typed, 31
programming language constructs, 13
pronunciation, determining if two words are
pronounced similarly, 159
properties, OOP, 557
protected access specifier, 580
proxy user, accessing databases, 652–653
public access specifier, 580
689
Q
quantifiers, 164–165
queries, 389
accessing query result information,
479–481
closing query results, 479
retrieving records, 473–481
SQL. See MySQL; structured query
language (SQL)
query results, closing, 479
query strings, saving state information,
515–517
question mark (?)
conditional operators, 62
quantifier, 164
separating form data and URL tokens, 192
special operator, 58
R
RDBMSs (relational database management
systems), 389
readdir() function, 238
readfile() function, 254
reading
cookies, 526–529
data, incrementally, 275–277
directories, 238–241
entire files, 262–266
INDEX
records,
databases, 381, 412–427
adding,
412–415
adding to MySQL databases,
464–465
aggregate functions, 418–420
deleting, 427, 465–466
filtering query results, 423–425
retrieving, 415–418
sorting query results, 421–423
updating, 425–426, 465
redisplaying All-in-One forms, 210–212
reference, passing parameters by, 80–81
reference data type, 30
register_globals directive, disabling,
653
regular expressions, 160–170
defining character classes, 166–169
matching characters, 162–163
matching characters at beginning and end
of a string, 163
matching multiple pattern choices, 169
matching special characters, 163–164
pattern modifiers, 169–170
specifying quantity, 164–165
specifying subexpressions, 165–166
writing regular expression patterns,
161–162
related table, 382
relational database(s), 382
relational database management systems
(RDBMSs), 389
removing. See deleting
rename() function, 280–281, 282
renaming
columns in database tables, 407
database tables, 407
directories, 280–281
files, 280–281
repeating code. See loop statements
reporting errors, 653, 657–658
MySQL, 451–452
setting error reporting level, 659–661
$_REQUEST[] autoglobal array, avoiding,
650
require() function, 651
require statements, 109–111
require_once() function, 651
reset() function, 323, 325
690
“resource” data type, 30
result pointers, 459–460
resultsets, 459–460
retrieving records, 415–418, 473–481
accessing query result information,
479–481
into associative array, 477–478
closing query results, 479
into indexed array, 474–477
working with query results, 473–478
retrieving submitted data, 194–198
return statements, 78–81
revoking privileges, 411–412
rewinddir() function, 238
rmdir() function, 282
rsort() function, 337, 338–339, 342, 343
run-time errors, 656
S
saving state information. See state
information
scandir() function, 238
schemas, databases, 388
scientific notation, 31
scope, variables, 82–83
script(s). See PHP script(s)
<script> element, 6–7
script output, examining, 664–665
secondary arrays, 344
secure argument, cookies, 526
secure coding, 648–654
accessing databases through proxy users,
652–653
avoiding $_REQUEST[] autoglobal array,
650
changing settings in php.ini, 653–654
storing code in external files, 651–652
validating submitted form data,
649–650
validating user identities using sessions,
650–651
SELECT statement, 415–418, 419–425
select_db() function, 566
selecting
databases, 400–401, 455–458
files, 247
INDEX
member
selection notation, 564
serialization, 582–583
serialization functions, 594–599
serialize() function, 594
session(s)
deleting, 536–537
saving state information, 530–537
starting, 531–532
validating user identities, 650–651
working with session variables, 532–536
session IDs, 531
session variables, 532–536
setcookie() function, 519, 520, 522
settype() function, 59
short PHP script delimiters, 8–9
SHOW TABLES LIKE command, 461
shuffle() function, 343
similar_text() function, 158
simple key, 383
simple string syntax, 131
single quotation mark (’)
conversion, 138
format control strings, 641
values in style definitions, 634
__sleep() function, 594–595
sleep() method, 582
sort() function, 337, 338–342
sorting
arrays, 336–343
query results, 421–423
soundex() function, 159
source code, viewing, 665
special characters
matching, 163–164
Web forms, handling, 196–198
special operators, 58
sprintf() function. See formatting strings
spyware, 530
SQL. See MySQL; structured query language
(SQL)
SQL Server, 671–674
square brackets ([])
array elements operator, 61
special operator, 58
starting sessions, 531–532
state information, 496–539
saving using cookies, 517–529
saving using hidden forms, 506–515
saving using query strings, 515–517
saving using sessions, 530–537
statefulness, 497
statelessness, 497
statements, 3–4. See also specific statement
names
loop. See loop statements
static typing, 31
status messages, displaying for users, 207–208
STDDEV() function, 418
STDDEV_POP() function, 418
STDDEV_SAMP() function, 418
STD() function, 418
stick forms, 203
storing
classes in external files, 576–577
code in external files, 651–652
uploaded files, 249–252
strcasecmp() function, 156, 157–158
strchr() function, 142
strcmp() function, 156–157
stream(s), 267. See also file streams
stream_get_line() function, 275
strict equal operator (===), 51
strict not equal operator (!==), 51
string(s), 124–172
comparing. See comparing strings
constructing, 125–133
converting between strings and arrays,
151–153
counting characters and words,
134–135
dividing into smaller pieces,
147–151
encoding and decoding, 138–139
escape characters and sequences,
128–131
formatting. See formatting strings
modifying case, 135–138
parsing, 141
regular expressions. See regular
expressions
returning portions, 139
string operators, 126–128
strrev() function, 139
str_shuffle() function, 139
691
INDEX
string(s),
124–172 (continued)
substr()
function,
139
substrings.
See substrings
syntax, 131–133
trim() function, 139
string data, validating, 200–201
(string) operator, 58, 61
string operators, 126–128
stripslashes() function, 197
str_ireplace() function, replacing
strongly typed programming languages, 31
strpos() function, 142
strrchr() function, 142–143
str_replace() function, replacing
strrev() function, 140
strtok() function, 147–151
strtolower() function, 135–136
strtoupper() function, 135, 136
structured query language (SQL), 389,
390–391
keywords, 391
MySQL. See MySQL
style(s), CSS, 631–635
external, 635
inline, 632, 635
internal, 632–634, 635
style sheets
external (linked), 634–635
internal, 635
subexpressions, specifying, 165–166
subpatterns, specifying, 165–166
substr() function, 139
substrings, 141–147
finding and extracting, 141–144
replacing, 144–147
subtraction operator (-), 42
SUM() function, 418
superglobals, 189–191
switch statements, 92–95
nested, 89–92
symbolic links, 243
syntax errors, 655–656
creating, 404–406
deleting, 408
MySQL tables. See MySQL tables
phpMyAdmin, 432–433
removing, 407
renaming, 407
specifying field data types, 402–404
table relationships, 382–388
table relationships, databases, 382–388
tags, XHTML, 628–629
temporary cookies, 518
text editors, installing, 620–625
text files, 234
text hyperlinks, 214
$this reference, 585
tilde (˜), separator string, 302
tokens, 147–151
tracing errors with echo statements,
661–662
transformer functions, 588–594
trim() function, 139
two-dimensional arrays
associative, 355–356
indexed, 352–355
two-part forms, 209
type casting, 59–61
type specifiers, 642–643
692
U
uaksort() function, 337
ucfirst() function, 136, 137
ucwords() function, 136, 137
uksort() function, 337
T
table(s), 402–408
altering, 406–407
columns. See columns, database tabless
UML (Unified Modeling Language),
558
unary operators, 41
arithmetic, 44–48
Unicode, 674
Unified Modeling Language (UML),
558
unlink() function, 281–282
unset() function, 313
UPDATE statement, 425–426
updating database records, 425–426, 465
uploading files, 247–252
retrieving file information, 248
selecting files, 247
INDEX
storing
uploaded files, 249–252
URL tokens, 192–193
user privileges. See privileges, MySQL
usort() function, 337
WAMP
accessing WampServer online,
639
installing, 636–638
installing directory structure for student
files, 640
testing installation, 638–639
WampServer menu, 639
warning messages, 658
W3C (World Wide Web Consortium),
625
Web browser, displaying errors, 659
Web forms
All-in-One. See All-in-One forms
arrays, 359–364
data. See form data
e-mailing, 206–207
two-part, 209
XHTML, 191–194
Web page templates, 212–213
navigating within, 214
Web servers, configuring, 636–640
WHERE keyword, 423
while statements, 96–100
words
counting instrings, 134–135
determining of two words are pronounced
similarly, 159
World Wide Web Consortium (W3C),
625
write permission, precautions, 259
writing
data, incrementally, 270–272
entire files, 257–262
V
validation
All-in-One forms, 209
CSS styles, 635
data entered in forms, 199–201
submitted form data, 649–650
user identities, using sessions,
650–651
XHTML documents, 629–631
value(s)
attributes, 629
determining if a value exists,
328–333
determining if form variables contain,
199
passing parameters by, 80
returning, 78–81
value argument, cookies, 519–521
var keyword, 580
var_dump() function, 662
variables, 22–27
declaring, 23
determining if form variables contain
values, 199
displaying, 24–25
environmental, 190
global, 82–83
initializing, 23–24
local, 82
modifying, 25–27
naming, 23
scope, 82–83
session, 532–536
VARIANCE() function, 418, 419
VAR_POP() function, 418
VAR_SAMP() function, 418
viewing. See also displaying
source code, 665
693
X
xAMP
installing, 636–638
testing installation, 638–639
XHTML, 620–635
advanced escaping from, 204
CSSs, 631–635
DOCTYPE declarations, 625–626
document structure, 627
installing editors, 620–625
lowercase markup tags, 628
nested tags, 628–629
W
__wakeup() function, 595
wakeup() method, 582