These are the bugs found so far in the second edition.
Erik Wiersma pointed out that the postForm function that’s part of
the BBS example in Chapter 17 uses $PHP_SELF, but can’t actually get
to it without first declaring it as a global. This is listing 17-7
on page 636. Please add
to the top of the function, before the first print statement.
Richard Tape noticed that Listing 15.1 on page 582 has a missing dash in
its for loop on line 11. The correct line should be
for($position = $limit-1; $position >= $bubble; $position--)
Dan Barber used the session-handling code in Chapter 17 (Listing 17.5,
page 631) in a live site, which is cool except for one issue. The random
number generator is being seeded with the output of time(). This is
the number of seconds on the clock. So, if two people request a session
identifier during the same second, they’ll get the same identifier. That’s
not good at all.
The fix is to use something that will change a lot more often. I suggest
using (double)microtime()*100000000.00 in place of time(). But let me stress
that it’s probably better to use the built-in session handling available in
Alvin Koh pointed out that Figure 7.2 is labeled correctly, but it’s the wrong
code. It should be demonstrating environment variables. The file on the CDROM
is correct. Here’s what it should be in the book:
You're using to see this page.<BR>
Anthony Boyd discovered the glaring error in Listing 15.6. The code there is not
right at all! Here’s the correct example:
<PRE>Array ( [hours] => 18 [mday] => 23 [minutes] => 41  => 1495564916 [mon] => 5 [month] => May [seconds] => 56 [wday] => 2 [weekday] => Tuesday [yday] => 142 [year] => 2017 ) </PRE>
Thanks for bringing this to my attention, Anthony!
Andrew Harrowing pointed out a typo in the example on page 514. Change the line
and it will really print out the message body. Thanks, Andrew!
Murray Moffatt wrote to tell me about the missing right parenthesis in the code
on page 207. Thanks, Murray!
Murray Moffatt also notified me that imagejpeg() now uses quality values from 0 to 100.
Page 367 describes this function. Thanks again, Murray!
Dave Patton sent me these tidbits.
Page 67, mid-page, “Chapter 20” should be “Chapter 21”.
Page 175, last line “Chapter 21” should be “Chapter 22”.
Page 242, the comment “//set up array of color names” in the array_values example belongs with the array_walk example.
Page 267, strspn, “position in the” should be “position of the”.
Page 276, Table 9.5, many of the entities are listed twice.
Page 394, dba_open, reference to Table 13.3 refers to “four types”, but Table 13.3 on next page lists five types.
Page 628, last paragraph, refers to database “store”, but example on prior page uses database “test”.
Page 714, last paragraph, URL contains
“21-5.php”, but example is talking about “21.3”. On the next page the script is referred to as “21-5.php”, but again, the listing is numbered 21.3, and the screen print shows the URL containing “21-3.php”.
Krishnan Renjith found an error in the example style guide.
On page 746, there’s a while loop that should be a for loop.
while($index = 0; $index < count($userName); $index++)
for($index = 0; $index < count($userName); $index++)
Matt Sadowski found a bug in the example for array_splice on page 241.
array_splice($colors, 2, 2);
array_splice($colors, 2, 1);
The description of this function talks about the third argument being
positional, but today it’s clearly a length argument.
Stuart Cooper pointed out that the book refers to a “tertiary” operator,
instead of a “ternary” operator. Of course, “tertiary” means third. “Ternary”
means having three parts and is the correct way to describe the ?: operator.
Alternatively, this operator could be described as “trinary”.