Errata

PHP in a Nutshell

Errata for PHP in a Nutshell

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 12
7th par

Hi,

It is two years ago that this book was printed. Is it possible that the instructions on installing Apache are somewhat out of date by now (Sept. 2008)?

Anyway, I followed the instructions carefully, but when I ran the services.msc command there was no Apache2 in the list. So I am stuck, rendering the book fairly useless.

Any help? I downloaded Apache 2.2.9

Regards,
Hans

____________________
Hans Teijgeler
Laanweg 28
1871 BJ Schoorl
The Netherlands
+31-72-509 2005
hans.teijgeler@quicknet.nl

Anonymous  Sep 22, 2008 
Printed Page 42
Returning by Reference

Paragraph ends "you use the normal reference assign that you learned earlier". However, AFAICT there is no earlier reference to =& assignments; the first real discussion of them in on page 57.

MadOverlord  Oct 11, 2009 
Printed Page 48
7th paragraph, paragraph following string example

The phrase "then the twelth character" should be "then the thirteenth character".

Note that the character referenced is $mystr{12} but since indexing starts at 0 is the 13th character. Earlier in the paragraph $mystr{0} is referenced as the first character.

Harry Thompson  Jan 17, 2012 
65
last code statement of array_diff description

$arr1_unique = array_merge($arr1, $arr2, $arr3, $arr4); should read:
$arr1_unique = array_diff($arr1, $arr2, $arr3, $arr4);

Leopoldo Garcia  Jul 05, 2011 
Printed Page 76
The Array Cursor

In this section a motif is introduced : list($var,$val) = each($array)

However, it is nowhere explained what each() actually returns, other than that it steps through $array. Nor is list() ever explained. And neither have entries in the glossary.

For other confused people, the answers are here:

http://php.net/manual/en/function.list.php

http://us.php.net/manual/en/function.each.php

MadOverlord  Oct 11, 2009 
ePub Page 86
for loop of imagefilledrectangle

The for loop for imagefilledrectangle() is incorrect.

The loop should go from $i=400 to $i=200.

When $i goes from 400 to 200, it creates numerous centered rectangles, but the loop from 200 to 0 redraws it in such a manner that it erases the previous drawing.


Anonymous  May 22, 2015 
Printed Page 87
7th paragraph

5 - 5 - 5 has only one value and associativity has nothing to do with it. It is not equivalent to 5 - (5 - 5) but to (-5 - 5) + 5 to put the second part first or 5 - (5 + 5) This is to do with the rules regarding brackets and signs. There is no associativity issue with all - and + .

Malcolm New  Dec 18, 2014 
Printed Page 97
dechex() paragraph

The sentence

The dechex() function converts a decimal number into a binary number.

should read

The dechex() function converts a decimal number into a hexadecimal number.

Anonymous   
Printed Page 98
empty() function, 1st paragraph

Current text:
"...if a variable was set and had a false value (such as 0 or an empty string),
empty() would return false, ..."

This is not so; empty() would return true. This text contradicts the first sentence
in the paragraph.

The same error appears on page 104 in the description of the isset() function.

Anonymous   
Printed Page 104
md5() function description

Book says "An MD5 checksum is 32 bytes long, which is equal to 128 bits," but since a byte is 8 bits, 8*32=256 bits which is wrong.
The correct answer is 128 bits which equals 16 bytes or 32 characters in HEX notation where each character represents 4 bits.

A problem also exists for sha1() on page 114.

Anonymous   
Printed Page 114
sha1() section

In the first sentence
SHA stands for the "Secure Hash Algorithm", and it is a way of converting a string of
any size into a 40-bit hexadecimal ...

40-bit should read 40-digit

In the 3rd paragraph, last sentence

If you have the passwords of people on your database ...
should read
If you have the checksummed passwords of people in your database ...

Anonymous   
Printed Page 114
sha1() definition

Book says "...it is a way of converting a string of any size into a 40-bit
hexadecimal number..."

The right answer is that it is 160-bits, 160/8=20 bytes. The 20 bytes uses 40
characters to display in hex notation.
-----
On the next page the book says at the end of the first paragraph "...can create a
checksum of strings of millions of characters in just 40 bytes."

The right answer is 20 bytes.


Anonymous   
Printed Page 116
Description of str_pad() has errors

Second parameter is final length of padded string, not amount to add. first example should be $newstring = str_pad($string, strlen($string) + 2);

Further examples need similar adjustment.

Default padding on my system is STR_PAD_RIGHT, not STR_PAD_BOTH.

php -v
PHP 5.1.4 (cli) (built: Sep 18 2006 19:11:27)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

built from source on a Macbook running OS X 10.4.9


Anonymous   
Printed Page 134
2nd paragraph under Access Control Modifiers

The word "word" should be changed to "world" in the sentence starting with "In an encapsulated word".

Anonymous   
Printed Page 135
example code

public should probably be removed from before both method/function
definitions to agree with the text description that it is not needed.

Anonymous   
Printed Page 144
2nd and 4th section of mono type (2nd and 4th examples)

I don't see where "Creating Poppy" gets printed anywhere. I think it should be:
Creating a dog: Poppy
Creating a poodle
blah blah

Anonymous   
Printed Page 148
First example

Last line in first example is:

print (int)($Joe === $Joe) . "
";

It should be:

print (int)($Bob === $Joe) . "
";

Anonymous   
PDF Page 240
1st

"The preg_match() function has a FORTH parameter.."
How come i see only three parameters...

and again in the source code there is a reference to the %myarray even though it wasn't declared...
some parameter is obviously missing...

Anonymous  Jul 26, 2009 
Printed Page 247
Getting Arty - Example code

To get the output shown on the next page (248), the for loop in the example code should have the condition $i > 200 and not $i >0. The code should be:

for ($i=400, $j=300; $i>200; $i -= 4, $j -= 3) {

The squares are then correctly drawn all the way into the centre (400/2).

Kim Burton  Sep 01, 2009